summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/unit/headers_test.ts15
-rw-r--r--ext/fetch/20_headers.js2
2 files changed, 15 insertions, 2 deletions
diff --git a/cli/tests/unit/headers_test.ts b/cli/tests/unit/headers_test.ts
index 9db8a4862..fa711bb9b 100644
--- a/cli/tests/unit/headers_test.ts
+++ b/cli/tests/unit/headers_test.ts
@@ -1,5 +1,5 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
-import { assert, assertEquals } from "./test_util.ts";
+import { assert, assertEquals, assertThrows } from "./test_util.ts";
const {
inspectArgs,
// @ts-expect-error TypeScript (as of 3.7) does not support indexing namespaces by symbol
@@ -386,3 +386,16 @@ Deno.test(function customInspectReturnsCorrectHeadersFormat() {
`Headers { "content-length": "1337", "content-type": "application/json" }`,
);
});
+
+Deno.test(function invalidHeadersFlaky() {
+ assertThrows(
+ () => new Headers([["x", "\u0000x"]]),
+ TypeError,
+ "Header value is not valid.",
+ );
+ assertThrows(
+ () => new Headers([["x", "\u0000x"]]),
+ TypeError,
+ "Header value is not valid.",
+ );
+});
diff --git a/ext/fetch/20_headers.js b/ext/fetch/20_headers.js
index 5243c5029..ae32aec11 100644
--- a/ext/fetch/20_headers.js
+++ b/ext/fetch/20_headers.js
@@ -88,7 +88,7 @@
// Regex matching illegal chars in a header value
// deno-lint-ignore no-control-regex
- const ILLEGAL_VALUE_CHARS = /[\x00\x0A\x0D]/g;
+ const ILLEGAL_VALUE_CHARS = /[\x00\x0A\x0D]/;
/**
* https://fetch.spec.whatwg.org/#concept-headers-append