summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2011-12-20 02:44:32 +0000
committerJo-Philipp Wich <jow@openwrt.org>2011-12-20 02:44:32 +0000
commit6ae669da0676b77d6ed101f79cbd4cff1eec7616 (patch)
treef2bcb3a905a188e7baeebf21e85c104a725d495b /libs
parent78332ec7230a17e111d6472c2a3adacc8dc48e54 (diff)
libs/web: improve ip6addr datype validation, accept both CIDR and IP/Mask notation
Diffstat (limited to 'libs')
-rw-r--r--libs/web/htdocs/luci-static/resources/cbi.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/libs/web/htdocs/luci-static/resources/cbi.js b/libs/web/htdocs/luci-static/resources/cbi.js
index 4b8cd5c90..3826753ed 100644
--- a/libs/web/htdocs/luci-static/resources/cbi.js
+++ b/libs/web/htdocs/luci-static/resources/cbi.js
@@ -49,13 +49,15 @@ var cbi_validators = {
'ip4addr': function(v)
{
- if( v.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)(\/(\d+))?$/) )
+ if (v.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})(\/(\S+))?$/))
{
return (RegExp.$1 >= 0) && (RegExp.$1 <= 255) &&
(RegExp.$2 >= 0) && (RegExp.$2 <= 255) &&
(RegExp.$3 >= 0) && (RegExp.$3 <= 255) &&
(RegExp.$4 >= 0) && (RegExp.$4 <= 255) &&
- (!RegExp.$5 || ((RegExp.$6 >= 0) && (RegExp.$6 <= 32)))
+ ((RegExp.$6.indexOf('.') < 0)
+ ? ((RegExp.$6 >= 0) && (RegExp.$6 <= 32))
+ : (cbi_validators.ip4addr(RegExp.$6)))
;
}