Commit d591115
authored
fix(url): make URLSearchParams record constructor spec compliant (#295)
Fixes the issue where byte replacement characters could result in duplicate entries when constructing `URLSearchParams` from a record.
While current implementation follows the [spec](https://url.spec.whatwg.org/#urlsearchparams-initialize) to the word:
> Otherwise, if init is a [record](https://webidl.spec.whatwg.org/#idl-record), then [for each](https://infra.spec.whatwg.org/#map-iterate) name → value of init, [append](https://infra.spec.whatwg.org/#list-append) (name, value) to query’s [list](https://url.spec.whatwg.org/#concept-urlsearchparams-list).
using `params_append()` directly happens before the `USVString` conversion so that keys that are supposed to collide after conversion can be added as separate entries.
By using `params_set()` we get the correct behavior without having to normalize the record beforehand.
Extending `maybe_consume_sequence_or_record` with separate sequence and record handlers allows applying different behavior.
Passes 2 remaining tests for `URLSearchParams` constructor.1 parent 27d1d5d commit d591115
File tree
4 files changed
+22
-10
lines changed- builtins/web
- fetch
- runtime
- tests/wpt-harness/expectations/url
4 files changed
+22
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
650 | 650 | | |
651 | 651 | | |
652 | 652 | | |
653 | | - | |
| 653 | + | |
654 | 654 | | |
655 | 655 | | |
656 | 656 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
| 187 | + | |
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
202 | 214 | | |
203 | 215 | | |
204 | 216 | | |
| |||
207 | 219 | | |
208 | 220 | | |
209 | 221 | | |
210 | | - | |
| 222 | + | |
211 | 223 | | |
212 | 224 | | |
213 | 225 | | |
| |||
416 | 428 | | |
417 | 429 | | |
418 | 430 | | |
419 | | - | |
| 431 | + | |
420 | 432 | | |
421 | 433 | | |
422 | 434 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
0 commit comments