WebUI: prohibit strange special characters in password

Restricts password to A-Z, a-z, 0-9 and !#$%()*+,.:;=?@^_

Fixes #40

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Reviewed-by: Tim Niemeyer <tim@tn-x.org>
This commit is contained in:
Adrian Schmutzler 2017-05-30 22:04:42 +02:00 committed by Tim Niemeyer
parent d8a2b78856
commit 9fc20ae9cf
1 changed files with 4 additions and 0 deletions

View File

@ -3,8 +3,12 @@
<%
# write
if [ "$REQUEST_METHOD" == "POST" ] ; then
#check for special characters in password
regex='^[a-zA-Z0-9!#\$%\(\)\*\+,\.:;=\?@\^_]+$'
if [ "$POST_pass1" == "" ] ; then
MSG='<span class="red">Das Passwort darf nicht leer sein!</span>'
elif ! echo -n "$POST_pass1" | egrep -q "$regex"; then
MSG='<span class="red">Passwort enth&auml;lt ung&uuml;ltige Zeichen!</span>'
else
(echo "$POST_pass1"; sleep 1; echo "$POST_pass2") | passwd &>/dev/null
if [ $? -eq 0 ]; then