[Bug]: getHeader performs case-sensitive lookup on IncomingHttpHeaders and plain objects

Aperta
#43,954 1 commento 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@mrdeyroy ci sta già lavorando.

Dal 25/11/2026.

  • #43953 di @mrdeyroy — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
nodejs, typescript
Ambito
backend

Direzione di ricerca

The bug is in the getHeader helper in the @rocket.chat/tools package, where the lookup is a strict headers[key] access on IncomingHttpHeaders and plain objects. Start by reading that function and its HeaderLike type, then reproduce with getHeader({ 'content-type': 'application/json' }, 'Content-Type'). Done means lowercase-insensitive lookup works for all three input kinds (IncomingHttpHeaders, Headers, plain objects). The body says PR #43953 already contains a fix and tests, so check that before starting.

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

Descrizione

type: bug
Description:

In @rocket.chat/tools, getHeader performs a strictly case-sensitive lookup on IncomingHttpHeaders and plain objects:
return (headers[key] ?? '') as T;

HTTP header names are case-insensitive according to RFC 7230 §3.2 and RFC 9110 §5.1. Furthermore, Node.js HTTP servers (IncomingHttpHeaders) automatically lowercase all incoming header names.

When callers pass canonical or title-cased header names (e.g. getHeader(req.headers, 'Content-Type'), getHeader(req.headers, 'User-Agent'), getHeader(req.headers, 'X-Real-IP')), getHeader returns an empty string "" instead of the header value. Similarly, querying a plain object containing uppercase keys using lowercase names returns "".

Only Fetch API Headers instances worked case-insensitively because Headers.prototype.get() normalizes keys internally.

Steps to reproduce:
  1. Import getHeader from @rocket.chat/tools.
  2. Call getHeader({ 'content-type': 'application/json' }, 'Content-Type').
  3. Observe returned value is "" instead of "application/json".
Expected behavior:

Header lookups should be case-insensitive for all supported HeaderLike inputs (IncomingHttpHeaders, Headers, and plain objects), returning the header value regardless of key casing.

Actual behavior:

getHeader returns "" when the casing of the query key does not exactly match the key in IncomingHttpHeaders or the plain object.

Server Setup Information:
  • Version of Rocket.Chat Server: develop (9.2.0-develop)
  • Operating System: Linux
  • NodeJS Version: v24.21.0
Additional context:

PR #43953 contains the fix and regression test suite.

Lingua principale
TypeScript
Stelle
46.6k
Fork
14.2k
Merge medio
2g 21h
PR unite (30g)
302

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

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 RocketChat/Rocket.Chat

Tutte le issue di RocketChat/Rocket.Chat

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.