Skip to content

Commit d1cc21e

Browse files
Merge branch '5.4' into 6.2
* 5.4: [FrameworkBundle] Improve error message in MicroKernelTrait when using deprecated configureRoutes(RouteCollectionBuilder) with symfony/routing >= 6.0 Add warning about Symfony 5.2 changing pcntl_async_signals [Tests] Fix static calls and Mock var annotation [FrameworkBundle] Fix checkboxes check assertions [Notifier][WebProfilerBundle] Ignore messages whose `getNotification` returns `null` [HttpClient] Fix over-encoding of URL parts to match browser's behavior Fix Psalm job [HttpClient] Fix data collector [Tests] Migrate tests to static data providers [Semaphore] Fix test Fix: Split and clean up tests Remove unused data provider add Sender to the list of bypassed headers
2 parents 24ec434 + ecda6e7 commit d1cc21e

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

DataCollector/HttpClientDataCollector.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public function collect(Request $request, Response $response, \Throwable $except
4343

4444
public function lateCollect()
4545
{
46-
$this->data['request_count'] = 0;
47-
$this->data['error_count'] = 0;
46+
$this->data['request_count'] = $this->data['request_count'] ?? 0;
47+
$this->data['error_count'] = $this->data['error_count'] ?? 0;
4848
$this->data += ['clients' => []];
4949

5050
foreach ($this->clients as $name => $client) {
@@ -59,7 +59,8 @@ public function lateCollect()
5959

6060
$this->data['clients'][$name]['traces'] = array_merge($this->data['clients'][$name]['traces'], $traces);
6161
$this->data['request_count'] += \count($traces);
62-
$this->data['error_count'] += $this->data['clients'][$name]['error_count'] += $errorCount;
62+
$this->data['error_count'] += $errorCount;
63+
$this->data['clients'][$name]['error_count'] += $errorCount;
6364

6465
$client->reset();
6566
}

HttpClientTrait.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ private static function parseUrl(string $url, array $query = [], array $allowedS
540540
}
541541

542542
// https://tools.ietf.org/html/rfc3986#section-3.3
543-
$parts[$part] = preg_replace_callback("#[^-A-Za-z0-9._~!$&/'()*+,;=:@%]++#", function ($m) { return rawurlencode($m[0]); }, $parts[$part]);
543+
$parts[$part] = preg_replace_callback("#[^-A-Za-z0-9._~!$&/'()[\]*+,;=:@\\\\^`{|}%]++#", function ($m) { return rawurlencode($m[0]); }, $parts[$part]);
544544
}
545545

546546
return [
@@ -614,6 +614,31 @@ private static function mergeQueryString(?string $queryString, array $queryArray
614614
$queryArray = [];
615615

616616
if ($queryString) {
617+
if (str_contains($queryString, '%')) {
618+
// https://tools.ietf.org/html/rfc3986#section-2.3 + some chars not encoded by browsers
619+
$queryString = strtr($queryString, [
620+
'%21' => '!',
621+
'%24' => '$',
622+
'%28' => '(',
623+
'%29' => ')',
624+
'%2A' => '*',
625+
'%2B' => '+',
626+
'%2C' => ',',
627+
'%2F' => '/',
628+
'%3A' => ':',
629+
'%3B' => ';',
630+
'%40' => '@',
631+
'%5B' => '[',
632+
'%5C' => '\\',
633+
'%5D' => ']',
634+
'%5E' => '^',
635+
'%60' => '`',
636+
'%7B' => '{',
637+
'%7C' => '|',
638+
'%7D' => '}',
639+
]);
640+
}
641+
617642
foreach (explode('&', $queryString) as $v) {
618643
$queryArray[rawurldecode(explode('=', $v, 2)[0])] = $v;
619644
}

Tests/HttpClientTraitTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ public function provideParseUrl(): iterable
176176
yield [['http:', null, null, null, null], 'http:'];
177177
yield [['http:', null, 'bar', null, null], 'http:bar'];
178178
yield [[null, null, 'bar', '?a=1&c=c', null], 'bar?a=a&b=b', ['b' => null, 'c' => 'c', 'a' => 1]];
179-
yield [[null, null, 'bar', '?a=b+c&b=b', null], 'bar?a=b+c', ['b' => 'b']];
180-
yield [[null, null, 'bar', '?a=b%2B%20c', null], 'bar?a=b+c', ['a' => 'b+ c']];
181-
yield [[null, null, 'bar', '?a%5Bb%5D=c', null], 'bar', ['a' => ['b' => 'c']]];
182-
yield [[null, null, 'bar', '?a%5Bb%5Bc%5D=d', null], 'bar?a[b[c]=d', []];
183-
yield [[null, null, 'bar', '?a%5Bb%5D%5Bc%5D=dd', null], 'bar?a[b][c]=d&e[f]=g', ['a' => ['b' => ['c' => 'dd']], 'e[f]' => null]];
184-
yield [[null, null, 'bar', '?a=b&a%5Bb%20c%5D=d&e%3Df=%E2%9C%93', null], 'bar?a=b', ['a' => ['b c' => 'd'], 'e=f' => '']];
179+
yield [[null, null, 'bar', '?a=b+c&b=b-._~!$%26/%27()[]*+,;%3D:@%25\\^`{|}', null], 'bar?a=b+c', ['b' => 'b-._~!$&/\'()[]*+,;=:@%\\^`{|}']];
180+
yield [[null, null, 'bar', '?a=b+%20c', null], 'bar?a=b+c', ['a' => 'b+ c']];
181+
yield [[null, null, 'bar', '?a[b]=c', null], 'bar', ['a' => ['b' => 'c']]];
182+
yield [[null, null, 'bar', '?a[b[c]=d', null], 'bar?a[b[c]=d', []];
183+
yield [[null, null, 'bar', '?a[b][c]=dd', null], 'bar?a[b][c]=d&e[f]=g', ['a' => ['b' => ['c' => 'dd']], 'e[f]' => null]];
184+
yield [[null, null, 'bar', '?a=b&a[b%20c]=d&e%3Df=%E2%9C%93', null], 'bar?a=b', ['a' => ['b c' => 'd'], 'e=f' => '']];
185185
// IDNA 2008 compliance
186186
yield [['https:', '//xn--fuball-cta.test', null, null, null], 'https://fußball.test'];
187187
}

0 commit comments

Comments
 (0)