fix string/int length check
authorFelix Fietkau <nbd@openwrt.org>
Thu, 29 Sep 2005 18:58:42 +0000 (18:58 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 29 Sep 2005 18:58:42 +0000 (18:58 +0000)
SVN-Revision: 2007

openwrt/package/webif/files/usr/lib/webif/validate.awk

index 77d4ff695cae45006bdc932a050ea128bf0aec9f..c806400ca24360fd2612d1d5455a7080a643f3a9 100644 (file)
@@ -78,23 +78,21 @@ valid == 1 {
                if (options[i] == "required") {
                        if (value == "") { valid = 0; verr = "No value entered" }
                } else if ((options[i] ~ /^min=/) && (value != "")) {
+                       min = options[i]
+                       sub(/^min=/, "", min)
+                       min = int(min)
                        if ($1 == "int") {
-                               min = options[i]
-                               sub(/^min=/, "", min)
                                if (value < min) { valid = 0; verr = "Value too small" }
                        } else if ($1 == "string") {
-                               min = options[i]
-                               sub(/^min=/, "", min)
-                               if (length(value) < min) { valid = 0; verr = "Value too small" }
+                               if (length(value) < min) { valid = 0; verr = "Value too small: "  length(value) " < " min }
                        }
                } else if ((options[i] ~ /^max=/) && (value != ""))  {
+                       max = options[i]
+                       sub(/^max=/, "", max)
+                       max = int(max)
                        if ($1 == "int") {
-                               max = options[i]
-                               sub(/^max=/, "", max)
                                if (value > max) { valid = 0; verr = "Value too large" }
                        } else if ($1 == "string") {
-                               max = options[i]
-                               sub(/^max=/, "", max)
                                if (length(value) > max) { valid = 0; verr = "Value too large" }
                        }
                } else if ((options[i] == "nodots") && ($1 == "hostname")) {