From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 5 Feb 2008 19:32:04 -0000 Subject: [Cluster-devel] conga/luci cluster/resource_form_handlers.js c ... Message-ID: <20080205193204.31921.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: conga Changes by: rmccabe at sourceware.org 2008-02-05 19:32:04 Modified files: luci/cluster : resource_form_handlers.js validate_config_multicast.js luci/plone-custom: conga.js Log message: Fix 431105 Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource_form_handlers.js.diff?cvsroot=cluster&r1=1.42&r2=1.43 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_multicast.js.diff?cvsroot=cluster&r1=1.9&r2=1.10 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/plone-custom/conga.js.diff?cvsroot=cluster&r1=1.12&r2=1.13 --- conga/luci/cluster/resource_form_handlers.js 2008/01/02 20:52:22 1.42 +++ conga/luci/cluster/resource_form_handlers.js 2008/02/05 19:32:04 1.43 @@ -101,12 +101,13 @@ } var ipstr = form.ip_address.value; - var err = isValidHost(ipstr); + var err = isValidHost(ipstr, true); if (err) { errors.push('Error: \"' + ipstr + '\": ' + err); set_form_err(form.ip_address); - } else + } else { clr_form_err(form.ip_address); + } return (errors); } --- conga/luci/cluster/validate_config_multicast.js 2008/01/02 20:52:22 1.9 +++ conga/luci/cluster/validate_config_multicast.js 2008/02/05 19:32:04 1.10 @@ -74,9 +74,9 @@ errors.push('No multicast address was given.'); set_form_err(form.mcast_address); } else { - var err = isValidHost(form.mcast_address.value); + var err = isValidHost(form.mcast_address.value, true); if (err) { - errors.push(err); + errors.push('Error: \"' + form.mcast_address.value + '\": ' + err); set_form_err(form.mcast_address); } clr_form_err(form.mcast_address); --- conga/luci/plone-custom/conga.js 2008/01/22 15:02:33 1.12 +++ conga/luci/plone-custom/conga.js 2008/02/05 19:32:04 1.13 @@ -196,18 +196,22 @@ } } -function isValidHost(str) { +function isValidHost(str, iponly) { var i = str.split('.'); if (i.length === 1) { - return ('Hostnames must be fully qualified.'); + if (iponly) { + return ('You must enter an IP address in quad-dot notation.'); + } else { + return ('Hostnames must be fully qualified.'); + } } - if (i.length === 4 && !isNaN(parseInt(i[3]))) { - var o1 = parseInt(i[0]); - var o2 = parseInt(i[1]); - var o3 = parseInt(i[2]); - var o4 = parseInt(i[3]); + if (i.length === 4 && !isNaN(parseInt(i[3], 10))) { + var o1 = parseInt(i[0], 10); + var o2 = parseInt(i[1], 10); + var o3 = parseInt(i[2], 10); + var o4 = parseInt(i[3], 10); if (isNaN(o1) || isNaN(o2) || isNaN(o3) || ((o1 & 0xff) !== o1) || @@ -215,17 +219,21 @@ ((o3 & 0xff) !== o3) || ((o4 & 0xff) !== o4)) { - return ('Invalid IP Address.'); + return ('Invalid IP address.'); } return (null); } - if (!isNaN(parseInt(i[i.length - 1]))) { - return ('Invalid IP Address.'); + if (!isNaN(parseInt(i[i.length - 1], 10))) { + return ('Invalid IP address.'); + } + + if (iponly) { + return ('You must enter an IP address in quad-dot notation.'); } - if (!str.match(/^[0-9A-Za-z][0-9A-Za-z.-]*$/)) { + if (!str.match(/^[0-9A-Za-z][0-9A-Za-z.\-]*$/)) { return ('Hostnames can contain only alphanumeric characters and hyphens.'); }