Address review feedback: fix hostname regex, use CSS class for NWC warning banner, clarify test comment
This commit is contained in:
committed by
GitHub
parent
768f26027e
commit
154988bbeb
@@ -4091,8 +4091,11 @@ def _validate_safe_name(name: str) -> bool:
|
|||||||
return bool(name) and _SAFE_NAME_RE.match(name) is not None
|
return bool(name) and _SAFE_NAME_RE.match(name) is not None
|
||||||
|
|
||||||
|
|
||||||
# Hostname characters: letters, digits, hyphens, dots (no underscores in FQDNs)
|
# Hostname characters: letters, digits, hyphens only within labels; dots separate labels.
|
||||||
_HOSTNAME_RE = re.compile(r'^[a-z0-9]([a-z0-9\-\.]*[a-z0-9])?$')
|
# Each label must start and end with a letter or digit; no consecutive dots.
|
||||||
|
_HOSTNAME_RE = re.compile(
|
||||||
|
r'^[a-z0-9]([a-z0-9\-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9\-]*[a-z0-9])?)*$'
|
||||||
|
)
|
||||||
|
|
||||||
# Managed domain keys that produce Caddy virtual-host blocks (excluding sslemail)
|
# Managed domain keys that produce Caddy virtual-host blocks (excluding sslemail)
|
||||||
_MANAGED_DOMAIN_KEYS: frozenset[str] = frozenset([
|
_MANAGED_DOMAIN_KEYS: frozenset[str] = frozenset([
|
||||||
|
|||||||
@@ -171,3 +171,15 @@ domain-field-actions {
|
|||||||
.port-req-status {
|
.port-req-status {
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ── Wallet Connections unique-hostname warning ───────────────────── */
|
||||||
|
|
||||||
|
.domain-nwc-warning {
|
||||||
|
margin-bottom: 14px;
|
||||||
|
padding: 10px 14px;
|
||||||
|
background: rgba(255, 180, 0, 0.10);
|
||||||
|
border: 1px solid var(--warning-color, #f59e0b);
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 0.88rem;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ function openDomainSetupModal(feat, onSaved) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var nwcWarning = isWalletConnections
|
var nwcWarning = isWalletConnections
|
||||||
? '<div style="margin-bottom:14px;padding:10px 14px;background:rgba(255,180,0,0.10);border:1px solid var(--warning-color,#f59e0b);border-radius:8px;font-size:0.88rem;line-height:1.6;">' +
|
? '<div class="domain-nwc-warning">' +
|
||||||
'<strong>⚠ Wallet Connections requires its own unique hostname.</strong> ' +
|
'<strong>⚠ Wallet Connections requires its own unique hostname.</strong> ' +
|
||||||
'Use a new subdomain such as <code>lightning.yourdomain.com</code>, or a separate domain. ' +
|
'Use a new subdomain such as <code>lightning.yourdomain.com</code>, or a separate domain. ' +
|
||||||
'Do not reuse a domain already assigned to Matrix, Nextcloud, WordPress, BTCPay Server, Vaultwarden, Haven, or another Caddy site.' +
|
'Do not reuse a domain already assigned to Matrix, Nextcloud, WordPress, BTCPay Server, Vaultwarden, Haven, or another Caddy site.' +
|
||||||
@@ -193,7 +193,7 @@ function openDomainReconfigureModal(feat, existingDomain, onSaved) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var nwcWarning = isWalletConnections
|
var nwcWarning = isWalletConnections
|
||||||
? '<div style="margin-bottom:14px;padding:10px 14px;background:rgba(255,180,0,0.10);border:1px solid var(--warning-color,#f59e0b);border-radius:8px;font-size:0.88rem;line-height:1.6;">' +
|
? '<div class="domain-nwc-warning">' +
|
||||||
'<strong>⚠ Wallet Connections requires its own unique hostname.</strong> ' +
|
'<strong>⚠ Wallet Connections requires its own unique hostname.</strong> ' +
|
||||||
'Use a new subdomain such as <code>lightning.yourdomain.com</code>, or a separate domain. ' +
|
'Use a new subdomain such as <code>lightning.yourdomain.com</code>, or a separate domain. ' +
|
||||||
'Do not reuse a domain already assigned to Matrix, Nextcloud, WordPress, BTCPay Server, Vaultwarden, Haven, or another Caddy site.' +
|
'Do not reuse a domain already assigned to Matrix, Nextcloud, WordPress, BTCPay Server, Vaultwarden, Haven, or another Caddy site.' +
|
||||||
|
|||||||
@@ -165,7 +165,10 @@ class ValidateHostnameTests(unittest.TestCase):
|
|||||||
self.assertFalse(server._validate_hostname(""))
|
self.assertFalse(server._validate_hostname(""))
|
||||||
|
|
||||||
def test_invalid_trailing_dot(self):
|
def test_invalid_trailing_dot(self):
|
||||||
# After normalization a trailing dot should have been removed.
|
# The hostname validator rejects trailing dots directly.
|
||||||
|
# In the API flow, normalization removes exactly one trailing dot before
|
||||||
|
# this validator is called, so a single trailing dot in user input is
|
||||||
|
# handled before reaching validation.
|
||||||
self.assertFalse(server._validate_hostname("foo.example.com."))
|
self.assertFalse(server._validate_hostname("foo.example.com."))
|
||||||
|
|
||||||
def test_invalid_with_underscore(self):
|
def test_invalid_with_underscore(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user