-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb: Ensure Headers API can handle non-ascii characters
This patch ensure Headers object's associated header list is ISO-8859-1 encoded when set using `Infra::isomorphic_encode`, and correctly decoded using `Infra::isomorphic_decode`.
- Loading branch information
Showing
5 changed files
with
111 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
Tests/LibWeb/Text/expected/Fetch/fetch-headers-get-non-ascii.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
before-æøå-after | ||
before-ß-after |
34 changes: 34 additions & 0 deletions
34
Tests/LibWeb/Text/expected/Fetch/fetch-headers-non-ascii.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-------------------------------- | ||
Headers constructor | ||
-------------------------------- | ||
Accept: before-æøå-after | ||
X-Test: before-ß-after | ||
|
||
-------------------------------- | ||
Headers.append() | ||
-------------------------------- | ||
Accept: before-æøå-after | ||
X-Test: before-ß-after | ||
|
||
-------------------------------- | ||
Headers.set() | ||
-------------------------------- | ||
Accept: before-æøå-after | ||
X-Test: before-ß-after | ||
|
||
-------------------------------- | ||
Headers.getSetCookie() | ||
-------------------------------- | ||
Set-Cookie: before-æøå-after | ||
|
||
-------------------------------- | ||
Headers iterator | ||
-------------------------------- | ||
accept: before-æøå-after | ||
x-test: before-ß-after | ||
|
||
-------------------------------- | ||
Headers.forEach() | ||
-------------------------------- | ||
accept: before-æøå-after | ||
x-test: before-ß-after |
66 changes: 66 additions & 0 deletions
66
Tests/LibWeb/Text/input/Fetch/fetch-headers-non-ascii.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<!DOCTYPE html> | ||
<script src="../include.js"></script> | ||
<script> | ||
// This test ensures that the Headers get() methods can handle non-ASCII latin1 characters: code points U+0080-U+00FF. | ||
test(() => { | ||
println("--------------------------------"); | ||
println("Headers constructor") | ||
println("--------------------------------"); | ||
const headers = new Headers({ | ||
"Accept": "before-æøå-after", | ||
"X-Test": "before-ß-after" | ||
}); | ||
println("Accept: " + headers.get("Accept")); | ||
println("X-Test: " + headers.get("X-Test")); | ||
|
||
println("\n--------------------------------"); | ||
println("Headers.append()") | ||
println("--------------------------------"); | ||
const headers2 = new Headers(); | ||
headers2.append("Accept", "before-æøå-after"); | ||
headers2.append("X-Test", "before-ß-after"); | ||
println("Accept: " + headers2.get("Accept")); | ||
println("X-Test: " + headers2.get("X-Test")); | ||
|
||
println("\n--------------------------------"); | ||
println("Headers.set()") | ||
println("--------------------------------"); | ||
const headers3 = new Headers({ | ||
"X-Test": "should be overwritten" | ||
}); | ||
headers3.set("Accept", "before-æøå-after"); | ||
headers3.set("X-Test", "before-ß-after"); | ||
println("Accept: " + headers3.get("Accept")); | ||
println("X-Test: " + headers3.get("X-Test")); | ||
|
||
println("\n--------------------------------"); | ||
println("Headers.getSetCookie()") | ||
println("--------------------------------"); | ||
const headers4 = new Headers({ | ||
"Set-Cookie": "before-æøå-after", | ||
}); | ||
println("Set-Cookie: " + headers4.getSetCookie()); | ||
|
||
println("\n--------------------------------"); | ||
println("Headers iterator") | ||
println("--------------------------------"); | ||
const headers5 = new Headers({ | ||
"Accept": "before-æøå-after", | ||
"X-Test": "before-ß-after" | ||
}); | ||
for (const [key, value] of headers5) { | ||
println(`${key}: ${value}`); | ||
} | ||
|
||
println("\n--------------------------------"); | ||
println("Headers.forEach()") | ||
println("--------------------------------"); | ||
const headers6 = new Headers({ | ||
"Accept": "before-æøå-after", | ||
"X-Test": "before-ß-after" | ||
}); | ||
headers6.forEach((value, key) => { | ||
println(`${key}: ${value}`); | ||
}); | ||
}); | ||
</script> |