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

Bare carriage returns in header line endings are still forwarded when separated from the CRLF by whitespace

Aperta
#13,624 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@RajaMuhammadAwais ci sta già lavorando.

Dal 15/9/2026.

  • #13691 di @RajaMuhammadAwais — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
networking

Direzione di ricerca

Inizia in mime_parser_parse e verifica la gestione di raw-print descritta nell’issue, quindi esegui test_proxy_hdrs. Controlla i casi request e parse_resp per i cinque terminatori di riga malformati, confermando al contempo che i campi ben formati e ripiegati mantengano un output byte per byte. Usa tests/gold_tests/headers/field_name_space.test.py come riferimento end-to-end per il comportamento a livello wire.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Follow-up to #12195 and #13595.

#13595 stops the raw input line from being preserved when the byte immediately before the terminating CRLF is a carriage return. That covers the line reported in #12195, but not the general case.

mime_parser_parse trims the field value with field_value.rtrim_if(&ParseRules::is_wslfcr), which strips SP and HT as well as CR and LF. So a bare CR only has to be separated from the CRLF by one space or tab to end up back in the raw-print pad and be forwarded unchanged.

Built on master with #13595 applied, output captured from HTTPHdr::print:

request header line serialized output
Extra-CRs: \r\r\r\r\n Extra-CRs: \r\n (fixed by #13595)
Extra-CRs: \r \r\n Extra-CRs: \r \r\n
Extra-CRs: \r\r \r\n Extra-CRs: \r\r \r\n
Extra-CRs: bar\r \r\n Extra-CRs: bar\r \r\n
Extra-CRs: \r\t\r\n Extra-CRs: \r\t\r\n

RFC 9112 section 2.2 says a recipient of a bare CR must either consider the element invalid or replace each bare CR with SP before processing or forwarding the message. The last four rows do neither.

A positional check will keep missing spellings of this. Making it structural works and keeps the fast path: once the value is trimmed, require that everything between the end of the value and the end of the line is optional whitespace followed by exactly one CRLF.

    // find value first
    field_value.ltrim_if(&ParseRules::is_ws);
    field_value.rtrim_if(&ParseRules::is_wslfcr);

    if (raw_print_field) {
      // Raw printing copies the original input bytes instead of re-serializing, so it would
      // replay this line ending verbatim. Everything between the end of the trimmed value and
      // the end of the line must be optional whitespace followed by exactly one CRLF; a bare
      // CR in there is malformed (RFC 9112 section 2.2) and must not be forwarded.
      TextView tail{field_value.data() + field_value.size(), parsed.data() + parsed.size()};
      if (tail.suffix(2) != "\r\n" || tail.remove_suffix(2).find_first_of("\r\n") != TextView::npos) {
        raw_print_field = false;
      }
    }

With that in place all five rows normalize to a single CRLF and test_proxy_hdrs stays green. Well-formed fields keep the raw fast path: X: a \r\n, X:\ta\r\n and a folded line are all still emitted byte for byte. The else if on the line ending goes away, as does the need for the size() > 2 guard, since suffix() clamps.

Three smaller items for the same change:

  1. The unit test fixture added in #13595 produces a raw-print pad of exactly 7, and mime_field_name_value_set only honors raw printing when the pad is 7 or less. One more CR and the pre-existing pad gate suppresses raw printing on its own, so the test would pass without any fix at all. It needs a comment saying so, plus a case that is not on the boundary.
  2. Only the request direction is covered. The same function serves responses, so a parse_resp case is cheap.
  3. tests/gold_tests/headers/field_name_space.test.py covers the sibling whitespace-before-colon case end to end. Because MIMEFieldBlockImpl::move_strings clears the raw flag on any string-heap relocation, whether these bytes reach the origin depends on heap state a unit test does not exercise, so a gold test with a raw-socket client would pin the actual wire contract.

This reproduces on 10.2.x and 10.1.x as well.

Lingua principale
C++
Stelle
2k
Fork
878
Merge medio
3g 16h
PR unite (30g)
91

Preparare l'ambiente

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 apache/trafficserver

Tutte le issue di apache/trafficserver

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.