Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

testTLD incorrectly reports valid TLDs with subdomains as invalid (e.g., a.example.com)

Aperta Adatta ai principianti
#5 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
php
Ambito
backend

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:

  • testTLD runs 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.com cause 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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di unraid/fix.common.problems

Tutte le issue di unraid/fix.common.problems

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.