Skip to content

Commit 5bc0d54

Browse files
committed
Fixes #12796
1 parent db7488a commit 5bc0d54

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/helpers/UrlHelper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ public static function buildQuery(array $params): string
8484
$params = [];
8585
foreach (explode('&', $query) as $param) {
8686
[$n, $v] = array_pad(explode('=', $param, 2), 2, '');
87-
$n = urldecode($n);
87+
// See https://github.com/craftcms/cms/issues/12796
88+
// $n = urldecode($n);
8889
$v = str_replace(['%2F', '%7B', '%7D'], ['/', '{', '}'], $v);
8990
$params[] = $v !== '' ? "$n=$v" : $n;
9091
}

tests/unit/helpers/UrlHelperTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,15 @@ public function buildQueryDataProvider(): array
279279
['foo=0', ['foo' => false]],
280280
['foo=1', ['foo' => true]],
281281
['foo=1&bar=2', ['foo' => 1, 'bar' => 2]],
282-
['foo[0]=1&foo[1]=2', ['foo' => [1, 2]]],
283-
['foo[bar]=baz', ['foo[bar]' => 'baz']],
284-
['foo[bar]=baz', ['foo' => ['bar' => 'baz']]],
282+
['foo%5B0%5D=1&foo%5B1%5D=2', ['foo' => [1, 2]]],
283+
['foo%5Bbar%5D=baz', ['foo[bar]' => 'baz']],
284+
['foo%5Bbar%5D=baz', ['foo' => ['bar' => 'baz']]],
285285
['foo=bar%2Bbaz', ['foo' => 'bar+baz']],
286-
['foo+bar=baz', ['foo+bar' => 'baz']],
286+
['foo%2Bbar=baz', ['foo+bar' => 'baz']],
287287
['foo=bar%5Bbaz%5D', ['foo' => 'bar[baz]']],
288288
['foo={bar}', ['foo' => '{bar}']],
289-
['foo[1]=bar', ['foo[1]' => 'bar']],
290-
['foo[1][bar]=1&foo[1][baz]=2', ['foo[1][bar]' => 1, 'foo[1][baz]' => 2]],
289+
['foo%5B1%5D=bar', ['foo[1]' => 'bar']],
290+
['foo%5B1%5D%5Bbar%5D=1&foo%5B1%5D%5Bbaz%5D=2', ['foo[1][bar]' => 1, 'foo[1][baz]' => 2]],
291291
];
292292
}
293293

@@ -568,6 +568,8 @@ public function encodeParamsDataProvider(): array
568568
['http://example.test?foo=bar+baz', 'http://example.test?foo=bar+baz'],
569569
['http://example.test?foo=bar+baz#hash', 'http://example.test?foo=bar baz#hash'],
570570
['http://example.test?foo=bar%2Bbaz#hash', 'http://example.test?foo=bar%2Bbaz#hash'],
571+
['http://example.test?foo%5B0%5D=bar%2Bbaz#hash', 'http://example.test?foo[0]=bar%2Bbaz#hash'],
572+
['http://example.test?foo%5B0%5D=bar&foo%5B1%5D=baz#hash', 'http://example.test?foo[0]=bar&foo[1]=baz#hash'],
571573
];
572574
}
573575

@@ -639,7 +641,7 @@ public function siteUrlDataProvider(): array
639641
return [
640642
['{siteUrl}endpoint', 'endpoint'],
641643
// https://github.com/craftcms/cms/issues/4778
642-
['{siteUrl}endpoint?param1=x&param2[0]=y&param2[1]=z', 'endpoint', 'param1=x&param2[]=y&param2[]=z'],
644+
['{siteUrl}endpoint?param1=x&param2%5B0%5D=y&param2%5B1%5D=z', 'endpoint', 'param1=x&param2%5B%5D=y&param2%5B%5D=z'],
643645
];
644646
}
645647

0 commit comments

Comments
 (0)