Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion scripts/js/settings-dhcp.js
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,10 @@ $(document).on("input blur paste", "#StaticDHCPTable td.static-hostname", functi
const val = $(this).text().trim();
if (val && !utils.validateHostnameStrict(val)) {
$(this).addClass("table-danger");
$(this).attr("title", "Invalid hostname: only letters, digits, hyphens, and dots allowed");
$(this).attr(
"title",
"Invalid hostname: letters, digits, hyphens, dots, and underscores allowed"
);
} else {
$(this).removeClass("table-danger");
$(this).attr("title", "");
Expand Down
4 changes: 1 addition & 3 deletions scripts/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,7 @@ function validateHostname(name) {
}

function validateHostnameStrict(name) {
// Hostnames must not contain spaces, commas, or characters invalid in DNS names
const hostnameValidator =
/^[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)*$/u;
const hostnameValidator = /^[a-zA-Z0-9][\w.-]*$/u;
return hostnameValidator.test(name.trim());
}

Expand Down
2 changes: 1 addition & 1 deletion settings-dhcp.lp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ PageTitle = "DHCP Settings"
<ul>
<li>Only one entry per MAC address is allowed.</li>
<li>IPv6 addresses must be enclosed in square brackets like <code>[2001:db8::1]</code>.</li>
<li>Only letters, digits, hyphens and dots are allowed in hostnames.</li>
<li>Static DHCP hostnames may contain letters, digits, hyphens, dots, and underscores, but must start with a letter or digit.</li>
</ul>
<br>
<div class="dhcp-hosts-wrapper mb-4">
Expand Down