testTLD incorrectly reports valid TLDs with subdomains as invalid (e.g., a.example.com)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Inizia da source/fix.common.problems/usr/local/emhttp/plugins/fix.common.problems/include/tests.php ed esamina la funzione testTLD e la sua attuale validazione di LOCAL_TLD. Verifica casi come a.example.com ed etichette non valide, quindi conferma che le etichette valide e il limite di lunghezza complessiva vengano accettati o rifiutati in base alle regole DNS indicate nell’issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
edit: 100% Copilot-generated. I don't know why it doesn't say that it was authored by copilot, but it was.
edit2: When this is fixed, it's probably worth adding the maximum length check of 255 octets too.
Bug Report
Affected Function: testTLD in tests.php
Problem
When the LOCAL_TLD is set to a value like a.example.com, the function currently splits on the dot and only checks the first label (e.g., a). Since the code enforces a minimum length of 2 for the TLD, any TLD where the first label is less than 2 characters (as in a.example.com) is incorrectly flagged as invalid, even though it is a valid FQDN.
What happens:
testTLDruns this logic:$TLDmain = explode('.', trim($unRaidVars['LOCAL_TLD']))[0]; if (strlen($TLDmain) < 2 || strlen($TLDmain) > 63 || preg_match('/[^a-zA-Z0-9\-]+/m', $TLDmain)) ...- This only validates the first label of the TLD, not the full TLD or all its labels.
- Inputs like
a.example.comcause false positives (invalid warning) even though each label is otherwise valid.
Expected Behavior
- Each label in the TLD (split by
.) should be checked against DNS rules:- Each label: 1-63 chars, only [a-zA-Z0-9-]
- Whole TLD: up to 253 chars (DNS)
- Dots should not be treated as invalid
- No unnecessary warning for valid subdomains like
a.example.com
Proposed Fix
Replace this block:
$TLDmain = explode('.', trim($unRaidVars['LOCAL_TLD']))[0];
if (!$unRaidVars['LOCAL_TLD'])
addWarning(...);
elseif (strlen($TLDmain) < 2 || strlen($TLDmain) > 63 || preg_match('/[^a-zA-Z0-9\-]+/m', $TLDmain))
addWarning(...);
With:
if (!$unRaidVars['LOCAL_TLD']) {
addWarning(...);
} else {
$tld_labels = explode('.', trim($unRaidVars['LOCAL_TLD']));
$invalid = false;
foreach ($tld_labels as $label) {
if (strlen($label) < 1 || strlen($label) > 63 || preg_match('/[^a-zA-Z0-9\-]/', $label)) {
$invalid = true;
break;
}
}
if ($invalid || strlen($unRaidVars['LOCAL_TLD']) > 253) {
addWarning(...);
}
}
References
Impact
- Users with valid FQDNs including subdomains may see incorrect warnings about invalid TLDs.
Environment
- Bug found in commit: 7056e6e452c27ae690a00f5b2dba1e164de40939
Let me know if a patch or PR is desired!
- Lingua principale
- PHP
- Stelle
- 0
- Fork
- 2
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di unraid/fix.common.problems
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
unraid/fix.common.problems#4 · 1 commento ·
Tutte le issue di unraid/fix.common.problems
Issue simili
-
tooling
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
UX
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
ProfessionalWiki/NeoWiki#1525 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
OpenConext/OpenConext-engineblock#2122 ·
-
Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Automattic/safe-publish#594 ·