Skip to content

Commit 97a6a1f

Browse files
Merge branch '4.4' into 5.1
* 4.4: fix merge Remove branch-version (keep them for contracts only) [HttpClient] relax auth bearer format requirements [PHPUnitBridge] Silence errors from mkdir() [DependencyInjection] Preload classes with union types correctly. [Serializer] fix decoding float XML attributes starting with 0 add missing dutch translations Support PHPUnit 8 and PHPUnit 9 in constraint compatibility trait Add expectDeprecation, expectNotice, expectWarning, and expectError to TestCase polyfill Add missing exporter function for PHPUnit 7 [Validator] Add missing romanian translations [Cache] Use correct expiry in ChainAdapter do not translate null placeholders or titles
2 parents bc1db73 + 3ead7e2 commit 97a6a1f

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

HttpClientTrait.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,13 @@ private static function prepareRequest(?string $method, ?string $url, array $opt
111111
throw new InvalidArgumentException(sprintf('Option "auth_basic" must be string or an array, "%s" given.', get_debug_type($options['auth_basic'])));
112112
}
113113

114-
if (isset($options['auth_bearer']) && (!\is_string($options['auth_bearer']) || !preg_match('{^[-._=:~+/0-9a-zA-Z]++$}', $options['auth_bearer']))) {
115-
throw new InvalidArgumentException(sprintf('Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, %s given.', \is_string($options['auth_bearer']) ? 'invalid string' : '"'.get_debug_type($options['auth_bearer']).'"'));
114+
if (isset($options['auth_bearer'])) {
115+
if (!\is_string($options['auth_bearer'])) {
116+
throw new InvalidArgumentException(sprintf('Option "auth_bearer" must be a string, "%s" given.', get_debug_type($options['auth_bearer'])));
117+
}
118+
if (preg_match('{[^\x21-\x7E]}', $options['auth_bearer'])) {
119+
throw new InvalidArgumentException('Invalid character found in option "auth_bearer": '.json_encode($options['auth_bearer']).'.');
120+
}
116121
}
117122

118123
if (isset($options['auth_basic'], $options['auth_bearer'])) {

Tests/HttpClientTraitTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,14 @@ public function testAuthBearerOption()
179179
public function testInvalidAuthBearerOption()
180180
{
181181
$this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException');
182-
$this->expectExceptionMessage('Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, "stdClass" given.');
182+
$this->expectExceptionMessage('Option "auth_bearer" must be a string, "stdClass" given.');
183183
self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => new \stdClass()], HttpClientInterface::OPTIONS_DEFAULTS);
184184
}
185185

186186
public function testInvalidAuthBearerValue()
187187
{
188188
$this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException');
189-
$this->expectExceptionMessage('Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, invalid string given.');
189+
$this->expectExceptionMessage('Invalid character found in option "auth_bearer": "a\nb".');
190190
self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => "a\nb"], HttpClientInterface::OPTIONS_DEFAULTS);
191191
}
192192

composer.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,5 @@
4646
"/Tests/"
4747
]
4848
},
49-
"minimum-stability": "dev",
50-
"extra": {
51-
"branch-version": "5.1"
52-
}
49+
"minimum-stability": "dev"
5350
}

0 commit comments

Comments
 (0)