Browse Source

Check hostname validity (#874)

rfm69
Xose Pérez 6 years ago
parent
commit
bbd323ec79
4 changed files with 3250 additions and 3230 deletions
  1. BIN
      code/espurna/data/index.html.gz
  2. +3230
    -3220
      code/espurna/static/index.html.gz.h
  3. +17
    -9
      code/html/custom.js
  4. +3
    -1
      code/html/index.html

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


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


+ 17
- 9
code/html/custom.js View File

@ -102,14 +102,6 @@ function keepTime() {
}
// http://www.the-art-of-web.com/javascript/validate-password/
function checkPassword(str) {
// at least one lowercase and one uppercase letter or number
// at least five characters (letters, numbers or special characters)
var re = /^(?=.*[A-Z\d])(?=.*[a-z])[\w~!@#$%^&*\(\)<>,.\?;:{}\[\]\\|]{5,}$/;
return re.test(str);
}
function zeroPad(number, positions) {
var zeros = "";
for (var i = 0; i < positions; i++) {
@ -147,9 +139,14 @@ function loadTimeZones() {
function validateForm(form) {
// http://www.the-art-of-web.com/javascript/validate-password/
// at least one lowercase and one uppercase letter or number
// at least five characters (letters, numbers or special characters)
var re_password = /^(?=.*[A-Z\d])(?=.*[a-z])[\w~!@#$%^&*\(\)<>,.\?;:{}\[\]\\|]{5,}$/;
// password
var adminPass1 = $("input[name='adminPass']", form).first().val();
if (adminPass1.length > 0 && !checkPassword(adminPass1)) {
if (adminPass1.length > 0 && !re_password.test(adminPass1)) {
alert("The password you have entered is not valid, it must have at least 5 characters, 1 lowercase and 1 uppercase or number!");
return false;
}
@ -160,6 +157,17 @@ function validateForm(form) {
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}$/;
var hostname = $("input[name='hostname']", form).val();
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 ('-')!");
return false;
}
return true;
}


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

@ -295,7 +295,9 @@
<div class="pure-u-0 pure-u-lg-1-2"></div>
<div class="pure-u-0 pure-u-lg-1-4"></div>
<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). For this setting to take effect you should restart the wifi interface by clicking the "Reconnect" button.
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 />
For this setting to take effect you should restart the wifi interface by clicking the "Reconnect" button.
</div>
</div>


Loading…
Cancel
Save