Escape file name

This commit is contained in:
Dennis Eichhorn 2018-08-11 11:09:09 +02:00
parent 1ee10359de
commit b1b3f4ee84
2 changed files with 10 additions and 10 deletions

View File

@ -4,7 +4,7 @@ isValidFileName() {
allownonascii="false"
if [ "$allownonascii" != "true" ] &&
test $(git diff --cached --name-only --diff-filter=A -z $1 |
test $(git diff --cached --name-only --diff-filter=A -z "$1" |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
return 0

View File

@ -24,37 +24,37 @@ hasInvalidPhpSyntax() {
hasInvalidHtmlTemplateContent() {
# Images must have a alt= attribute *error*
if [[ -n $(grep -P '(\<img)((?!.*?alt=).)*(>)' $1) ]]; then
if [[ -n $(grep -P '(\<img)((?!.*?alt=).)*(>)' "$1") ]]; then
return 1
fi
# Input elements must have a type= attribute *error*
if [[ -n $(grep -P '(<input)((?!.*?type=).)*(>)' $1) ]]; then
if [[ -n $(grep -P '(<input)((?!.*?type=).)*(>)' "$1") ]]; then
return 2
fi
# Form fields must have a name *error*
if [[ -n $(grep -P '(<input|<select|<textarea)((?!.*?name=).)*(>)' $1) ]]; then
if [[ -n $(grep -P '(<input|<select|<textarea)((?!.*?name=).)*(>)' "$1") ]]; then
return 3
fi
# Form must have a id, action and method *error*
if [[ -n $(grep -P '(\<form)((?!.*?(action|method|id)=).)*(>)' $1) ]]; then
if [[ -n $(grep -P '(\<form)((?!.*?(action|method|id)=).)*(>)' "$1") ]]; then
return 4
fi
# Inline css is invalid *warning*
if [[ -n $(grep -P '(style=)' $1) ]]; then
if [[ -n $(grep -P '(style=)' "$1") ]]; then
return 5
fi
# Attribute descriptions should not be hard coded *warning*
if [[ -n $(grep -P '(value|title|alt|aria\-label)(=\")((?!\<\?).)*(>)' $1) ]]; then
if [[ -n $(grep -P '(value|title|alt|aria\-label)(=\")((?!\<\?).)*(>)' "$1") ]]; then
return 6
fi
# Hard coded language *warning*
if [[ -n $(grep -P '(\<td\>|\<th\>|\<caption\>|\<label.*?(\"|l)\>)[0-9a-zA-Z\.\?]+' $1) ]]; then
if [[ -n $(grep -P '(\<td\>|\<th\>|\<caption\>|\<label.*?(\"|l)\>)[0-9a-zA-Z\.\?]+' "$1") ]]; then
return 7
fi
@ -72,12 +72,12 @@ isValidBashScript() {
hasInvalidBasicSyntax() {
# Check whitespace end of line in code
if [[ -n $(grep -P ' $' $1) ]]; then
if [[ -n $(grep -P ' $' "$1") ]]; then
return 1
fi
# Check for tabs
if [[ -n $(grep -P '\t' $1) ]]; then
if [[ -n $(grep -P '\t' "$1") ]]; then
return 2
fi