From a99882999fe7f6accb265eaaea546beb79b9c4fe Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 13 Jul 2018 11:48:29 +0200 Subject: [PATCH] Add more html checks based on css debug selectors --- Hooks/syntax.sh | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/Hooks/syntax.sh b/Hooks/syntax.sh index 20e3824..f662b45 100644 --- a/Hooks/syntax.sh +++ b/Hooks/syntax.sh @@ -27,7 +27,7 @@ if [[ "$FILE" =~ ^.+(php)$ ]]; then fi fi -# Html checks +# Html/template checks if [[ "$FILE" =~ ^.+(tpl\.php|html)$ ]]; then # Invalid and empty attributes if [[ -n $(grep -E '=\"[\#\$\%\^\&\*\(\)\\/\ ]*\"' $FILE) ]]; then @@ -49,6 +49,33 @@ if [[ "$FILE" =~ ^.+(tpl\.php|html)$ ]]; then grep -P '(\)' $FILE >&2 exit 1 fi + + # Input elements must have a type= attribute *error* + if [[ -n $(grep -P '(\)' $FILE) ]]; then + echo -e "\e[1;31m\tFound missing input type attribute.\e[0m" >&2 + grep -P '(\)' $FILE >&2 + exit 1 + fi + + # Form fields must have a name *error* + if [[ -n $(grep -P '(\)' $FILE) ]]; then + echo -e "\e[1;31m\tFound missing form element name.\e[0m" >&2 + grep -P '(\)' $FILE >&2 + exit 1 + fi + + # Form must have a id, action and method *error* + if [[ -n $(grep -P '(\)' $FILE) ]]; then + echo -e "\e[1;31m\tFound missing form element action, method or id.\e[0m" >&2 + grep -P '(\)' $FILE >&2 + exit 1 + fi + + # Inline css is invalid *warning* + if [[ -n $(grep -P '(style=)' $FILE) ]]; then + echo -e "\e[1;31m\tFound missing form element action, method or id.\e[0m" >&2 + grep -P '(style=)' $FILE >&2 + fi # Value fields should not be hard coded *warning* if [[ -n $(grep -P '(value=\")((?!\<\?).)*(>)' $FILE) ]]; then