mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 09:45:06 +02:00
LibWeb: Sort URLSearchParams using UTF-16 code units
We were previously sorting using code points which could give the wrong result for certain inputs. Fixes the last two failing tests on: https://wpt.live/url/urlsearchparams-sort.any.html
This commit is contained in:
committed by
Andreas Kling
parent
cff3e78a14
commit
d56da8cf9a
Notes:
github-actions[bot]
2024-08-17 05:45:28 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/d56da8cf9a0 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1081
@@ -0,0 +1,17 @@
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
function escapeUnicode(str) {
|
||||
return str.replace(/[\s\S]/g, function(c) {
|
||||
return '\\u' + ('0000' + c.charCodeAt(0).toString(16)).slice(-4);
|
||||
});
|
||||
}
|
||||
|
||||
test(() => {
|
||||
let params = new URLSearchParams("\uFFFD=x&\uFFFC&\uFFFD=a");
|
||||
params.sort();
|
||||
println(params.toString())
|
||||
for (const [key, value] of params) {
|
||||
println(`'${escapeUnicode(key)}' => '${escapeUnicode(value)}'`);
|
||||
}
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user