mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 23:56:06 +00: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:
parent
cff3e78a14
commit
d56da8cf9a
Notes:
github-actions[bot]
2024-08-17 05:45:28 +00:00
Author: https://github.com/shannonbooth
Commit: d56da8cf9a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1081
3 changed files with 31 additions and 13 deletions
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue