Browse Source

Check hostname does not start or end with an hyphen (#874)

rfm69
Xose Pérez 6 years ago
parent
commit
8a02c9fd69
4 changed files with 2696 additions and 2686 deletions
  1. BIN
      code/espurna/data/index.html.gz
  2. +2680
    -2677
      code/espurna/static/index.html.gz.h
  3. +15
    -8
      code/html/custom.js
  4. +1
    -1
      code/html/index.html

BIN
code/espurna/data/index.html.gz View File


+ 2680
- 2677
code/espurna/static/index.html.gz.h
File diff suppressed because it is too large
View File


+ 15
- 8
code/html/custom.js View File

@ -142,7 +142,7 @@ function validateForm(form) {
// http://www.the-art-of-web.com/javascript/validate-password/ // http://www.the-art-of-web.com/javascript/validate-password/
// at least one lowercase and one uppercase letter or number // at least one lowercase and one uppercase letter or number
// at least five characters (letters, numbers or special characters) // at least five characters (letters, numbers or special characters)
var re_password = /^(?=.*[A-Z\d])(?=.*[a-z])[\w~!@#$%^&*\(\)<>,.\?;:{}\[\]\\|]{5,}$/;
var re_password = new RegExp('^(?=.*[A-Z\d])(?=.*[a-z])[\w~!@#$%^&*\(\)<>,.\?;:{}\[\]\\|]{5,}$');
// password // password
var adminPass1 = $("input[name='adminPass']", form).first().val(); var adminPass1 = $("input[name='adminPass']", form).first().val();
@ -157,14 +157,20 @@ function validateForm(form) {
return false; return false;
} }
// The Internet standards (Requests for Comments) for protocols mandate that
// component hostname labels may contain only the ASCII letters 'a' through 'z'
// (in a case-insensitive manner), the digits '0' through '9', and the hyphen ('-').
var re_hostname = /^[A-Za-z\d-]{1,32}$/;
// RFCs mandate that a hostname's labels may contain only
// the ASCII letters 'a' through 'z' (case-insensitive),
// the digits '0' through '9', and the hyphen.
// Hostname labels cannot begin or end with a hyphen.
// No other symbols, punctuation characters, or blank spaces are permitted.
// Negative lookbehind does not work in Javascript
// var re_hostname = new RegExp('^(?!-)[A-Za-z0-9-]{1,32}(?<!-)$');
var re_hostname = new RegExp('^(?!-)[A-Za-z0-9-]{0,31}[A-Za-z0-9]$');
var hostname = $("input[name='hostname']", form).val(); var hostname = $("input[name='hostname']", form).val();
if (!re_hostname.test(hostname)) { if (!re_hostname.test(hostname)) {
alert("Hostname cannot be empty and may only contain the ASCII letters ('A' through 'Z' and 'a' through 'z'), the digits '0' through '9', and the hyphen ('-')!");
alert("Hostname cannot be empty and may only contain the ASCII letters ('A' through 'Z' and 'a' through 'z'), the digits '0' through '9', and the hyphen ('-')! They can neither start or end with an hyphen.");
return false; return false;
} }
@ -882,8 +888,9 @@ function initChannels(num) {
}; };
// add templates // add templates
var i = 0;
var template = $("#channelTemplate").children(); var template = $("#channelTemplate").children();
for (var i=0; i<max; i++) {
for (i=0; i<max; i++) {
var channel_id = start + i; var channel_id = start + i;
var line = $(template).clone(); var line = $(template).clone();
@ -895,7 +902,7 @@ function initChannels(num) {
} }
for (var i=0; i<num; i++) {
for (i=0; i<num; i++) {
$("select.islight").append( $("select.islight").append(
$("<option></option>").attr("value",i).text("Channel #" + i)); $("<option></option>").attr("value",i).text("Channel #" + i));
} }


+ 1
- 1
code/html/index.html View File

@ -296,7 +296,7 @@
<div class="pure-u-0 pure-u-lg-1-4"></div> <div class="pure-u-0 pure-u-lg-1-4"></div>
<div class="pure-u-1 pure-u-lg-3-4 hint"> <div class="pure-u-1 pure-u-lg-3-4 hint">
This name will identify this device in your network (http://&lt;hostname&gt;.local).<br /> This name will identify this device in your network (http://&lt;hostname&gt;.local).<br />
Hostname may contain only the ASCII letters 'a' through 'z' (in a case-insensitive manner), the digits '0' through '9', and the hyphen ('-').<br />
Hostname may contain only the ASCII letters 'a' through 'z' (in a case-insensitive manner), the digits '0' through '9', and the hyphen ('-'). They can neither start or end with an hyphen.<br />
For this setting to take effect you should restart the wifi interface by clicking the "Reconnect" button. For this setting to take effect you should restart the wifi interface by clicking the "Reconnect" button.
</div> </div>
</div> </div>


Loading…
Cancel
Save