8000 relax auth bearer format requirements · symfony/symfony@8b0b581 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8b0b581

Browse files
committed
relax auth bearer format requirements
1 parent 65b41de commit 8b0b581

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

src/Symfony/Component/HttpClient/HttpClientTrait.php

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

113-
if (isset($options['auth_bearer']) && (!\is_string($options['auth_bearer']) || !preg_match('{^[-._=:~+/0-9a-zA-Z]++$}', $options['auth_bearer']))) {
114-
throw new InvalidArgumentException(sprintf('Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, '.(\is_string($options['auth_bearer']) ? 'invalid string given.' : '"%s" given.'), \gettype($options['auth_bearer'])));
113+
if (isset($options['auth_bearer']) && (!\is_string($options['auth_bearer']))) {
114+
throw new InvalidArgumentException(sprintf('Option "auth_bearer" must be a string , "%s" given.', \gettype($options['auth_bearer'])));
115115
}
116116

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

src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,10 @@ 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, "object" given.');
182+
$this->expectExceptionMessage('Option "auth_bearer" must be a string , "object" given.');
183183
self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => new \stdClass()], HttpClientInterface::OPTIONS_DEFAULTS);
184184
}
185185

186-
public function testInvalidAuthBearerValue()
187-
{
188-
$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.');
190-
self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => "a\nb"], HttpClientInterface::OPTIONS_DEFAULTS);
191-
}
192-
193186
public function testSetAuthBasicAndBearerOptions()
194187
{
195188
$this->expectException('Symfony\Component\HttpClient\Exception\InvalidArgumentException');

0 commit comments

Comments
 (0)
0