Version: Deno 2.9.7
Headers returns an empty value instead of throwing when a header value contains CR or LF and also has leading or trailing whitespace. Reproduction:
for (const value of ["a\rb", " a\rb", "a\nb", " a\nb"]) {
try {
const headers = new Headers();
headers.append("x", value);
console.log(JSON.stringify(value), "->", JSON.stringify(headers.get("x")));
} catch (error) {
console.log(JSON.stringify(value), "->", error.name);
}
}
"a\rb" -> TypeError
" a\rb" -> ""
"a\nb" -> TypeError
" a\nb" -> ""
As I tested on Node and Bun, they both throw TypeError correctly:
"a\rb" -> TypeError
" a\rb" -> TypeError
"a\nb" -> TypeError
" a\nb" -> TypeError
Version: Deno 2.9.7
Headersreturns an empty value instead of throwing when a header value contains CR or LF and also has leading or trailing whitespace. Reproduction:As I tested on Node and Bun, they both throw
TypeErrorcorrectly: