Merge branch '4.3' into 4.4
* 4.3: [Cache] Fixed undefined variable in ArrayTrait [HttpClient] revert bad logic around JSON_THROW_ON_ERROR [HttpKernel] Fix handling non-catchable fatal errors Fix json-encoding when JSON_THROW_ON_ERROR is used [HttpFoundation] work around PHP 7.3 bug related to json_encode() [HttpClient] add $response->cancel() [Security] added support for updated \"distinguished name\" format in x509 authentication
This commit is contained in:
commit
d3055814ad
|
@ -26,7 +26,7 @@
|
||||||
"psr/container": "^1.0",
|
"psr/container": "^1.0",
|
||||||
"psr/link": "^1.0",
|
"psr/link": "^1.0",
|
||||||
"psr/log": "~1.0",
|
"psr/log": "~1.0",
|
||||||
"symfony/contracts": "^1.1.1",
|
"symfony/contracts": "^1.1.3",
|
||||||
"symfony/polyfill-ctype": "~1.8",
|
"symfony/polyfill-ctype": "~1.8",
|
||||||
"symfony/polyfill-intl-icu": "~1.0",
|
"symfony/polyfill-intl-icu": "~1.0",
|
||||||
"symfony/polyfill-intl-idn": "^1.10",
|
"symfony/polyfill-intl-idn": "^1.10",
|
||||||
|
|
|
@ -194,6 +194,7 @@ class JsonDescriptor extends Descriptor
|
||||||
private function writeData(array $data, array $options)
|
private function writeData(array $data, array $options)
|
||||||
{
|
{
|
||||||
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
|
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
|
||||||
|
|
||||||
$this->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n");
|
$this->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -797,9 +797,6 @@ class FrameworkExtension extends Extension
|
||||||
$container->setParameter('debug.error_handler.throw_at', 0);
|
$container->setParameter('debug.error_handler.throw_at', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$definition->replaceArgument(4, $debug);
|
|
||||||
$definition->replaceArgument(6, $debug);
|
|
||||||
|
|
||||||
if ($debug && class_exists(DebugProcessor::class)) {
|
if ($debug && class_exists(DebugProcessor::class)) {
|
||||||
$definition = new Definition(DebugProcessor::class);
|
$definition = new Definition(DebugProcessor::class);
|
||||||
$definition->setPublic(false);
|
$definition->setPublic(false);
|
||||||
|
|
|
@ -18,9 +18,10 @@
|
||||||
<argument type="service" id="logger" on-invalid="null" />
|
<argument type="service" id="logger" on-invalid="null" />
|
||||||
<argument>null</argument><!-- Log levels map for enabled error levels -->
|
<argument>null</argument><!-- Log levels map for enabled error levels -->
|
||||||
<argument>%debug.error_handler.throw_at%</argument>
|
<argument>%debug.error_handler.throw_at%</argument>
|
||||||
<argument>true</argument>
|
<argument>%kernel.debug%</argument>
|
||||||
<argument type="service" id="debug.file_link_formatter"></argument>
|
<argument type="service" id="debug.file_link_formatter"></argument>
|
||||||
<argument>true</argument>
|
<argument>%kernel.debug%</argument>
|
||||||
|
<argument>%kernel.charset%</argument>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="debug.file_link_formatter" class="Symfony\Component\HttpKernel\Debug\FileLinkFormatter">
|
<service id="debug.file_link_formatter" class="Symfony\Component\HttpKernel\Debug\FileLinkFormatter">
|
||||||
|
|
|
@ -72,16 +72,6 @@
|
||||||
<argument type="service" id="router" on-invalid="ignore" />
|
<argument type="service" id="router" on-invalid="ignore" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="http_exception_listener" class="Symfony\Component\HttpKernel\EventListener\ExceptionListener">
|
|
||||||
<tag name="kernel.event_listener" event="kernel.exception" method="onKernelException" priority="-2048" />
|
|
||||||
<tag name="kernel.reset" method="reset" />
|
|
||||||
<argument>null</argument>
|
|
||||||
<argument>null</argument>
|
|
||||||
<argument>%kernel.debug%</argument>
|
|
||||||
<argument>%kernel.charset%</argument>
|
|
||||||
<argument>%debug.file_link_format%</argument>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="validate_request_listener" class="Symfony\Component\HttpKernel\EventListener\ValidateRequestListener">
|
<service id="validate_request_listener" class="Symfony\Component\HttpKernel\EventListener\ValidateRequestListener">
|
||||||
<tag name="kernel.event_subscriber" />
|
<tag name="kernel.event_subscriber" />
|
||||||
</service>
|
</service>
|
||||||
|
|
|
@ -129,7 +129,7 @@ trait ArrayTrait
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$type = \is_object($value) ? \get_class($value) : \gettype($value);
|
$type = \is_object($value) ? \get_class($value) : \gettype($value);
|
||||||
$message = sprintf('Failed to save key "{key}" of type %s: %s', $type, $e->getMessage());
|
$message = sprintf('Failed to save key "{key}" of type %s: %s', $type, $e->getMessage());
|
||||||
CacheItem::log($this->logger, $message, ['key' => substr($id, \strlen($this->namespace)), 'exception' => $e]);
|
CacheItem::log($this->logger, $message, ['key' => $key, 'exception' => $e]);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,9 @@ class JsonDescriptor extends Descriptor
|
||||||
*/
|
*/
|
||||||
private function writeData(array $data, array $options)
|
private function writeData(array $data, array $options)
|
||||||
{
|
{
|
||||||
$this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0));
|
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
|
||||||
|
|
||||||
|
$this->write(json_encode($data, $flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -94,7 +94,8 @@ class JsonDescriptor extends Descriptor
|
||||||
|
|
||||||
private function writeData(array $data, array $options)
|
private function writeData(array $data, array $options)
|
||||||
{
|
{
|
||||||
$flags = $options['json_encoding'] ?? 0;
|
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
|
||||||
|
|
||||||
$this->output->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n");
|
$this->output->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -301,13 +301,7 @@ trait HttpClientTrait
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (\PHP_VERSION_ID >= 70300) {
|
$value = json_encode($value, $flags | (\PHP_VERSION_ID >= 70300 ? \JSON_THROW_ON_ERROR : 0), $maxDepth);
|
||||||
// Work around https://bugs.php.net/77997
|
|
||||||
json_encode(null);
|
|
||||||
$flags |= JSON_THROW_ON_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
$value = json_encode($value, $flags, $maxDepth);
|
|
||||||
} catch (\JsonException $e) {
|
} catch (\JsonException $e) {
|
||||||
throw new InvalidArgumentException(sprintf('Invalid value for "json" option: %s.', $e->getMessage()));
|
throw new InvalidArgumentException(sprintf('Invalid value for "json" option: %s.', $e->getMessage()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ trait ResponseTrait
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$content = json_decode($content, true, 512, JSON_BIGINT_AS_STRING | (\PHP_VERSION_ID >= 70300 ? JSON_THROW_ON_ERROR : 0));
|
$content = json_decode($content, true, 512, JSON_BIGINT_AS_STRING | (\PHP_VERSION_ID >= 70300 ? \JSON_THROW_ON_ERROR : 0));
|
||||||
} catch (\JsonException $e) {
|
} catch (\JsonException $e) {
|
||||||
throw new JsonException($e->getMessage(), $e->getCode());
|
throw new JsonException($e->getMessage(), $e->getCode());
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.1.3",
|
"php": "^7.1.3",
|
||||||
"psr/log": "^1.0",
|
"psr/log": "^1.0",
|
||||||
"symfony/http-client-contracts": "^1.1",
|
"symfony/http-client-contracts": "^1.1.3",
|
||||||
"symfony/polyfill-php73": "^1.11"
|
"symfony/polyfill-php73": "^1.11"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
|
|
@ -148,6 +148,10 @@ class JsonResponse extends Response
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $this->encodingOptions)) {
|
||||||
|
return $this->setJson($data);
|
||||||
|
}
|
||||||
|
|
||||||
if (JSON_ERROR_NONE !== json_last_error()) {
|
if (JSON_ERROR_NONE !== json_last_error()) {
|
||||||
throw new \InvalidArgumentException(json_last_error_msg());
|
throw new \InvalidArgumentException(json_last_error_msg());
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,10 @@ use Symfony\Component\Debug\ErrorHandler;
|
||||||
use Symfony\Component\Debug\ExceptionHandler;
|
use Symfony\Component\Debug\ExceptionHandler;
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
use Symfony\Component\EventDispatcher\Event;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
|
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
|
||||||
|
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||||
use Symfony\Component\HttpKernel\Event\KernelEvent;
|
use Symfony\Component\HttpKernel\Event\KernelEvent;
|
||||||
use Symfony\Component\HttpKernel\KernelEvents;
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
|
|
||||||
|
@ -39,6 +42,7 @@ class DebugHandlersListener implements EventSubscriberInterface
|
||||||
private $scream;
|
private $scream;
|
||||||
private $fileLinkFormat;
|
private $fileLinkFormat;
|
||||||
private $scope;
|
private $scope;
|
||||||
|
private $charset;
|
||||||
private $firstCall = true;
|
private $firstCall = true;
|
||||||
private $hasTerminatedWithException;
|
private $hasTerminatedWithException;
|
||||||
|
|
||||||
|
@ -51,7 +55,7 @@ class DebugHandlersListener implements EventSubscriberInterface
|
||||||
* @param string|FileLinkFormatter|null $fileLinkFormat The format for links to source files
|
* @param string|FileLinkFormatter|null $fileLinkFormat The format for links to source files
|
||||||
* @param bool $scope Enables/disables scoping mode
|
* @param bool $scope Enables/disables scoping mode
|
||||||
*/
|
*/
|
||||||
public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, ?int $throwAt = E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true)
|
public function __construct(callable $exceptionHandler = null, LoggerInterface $logger = null, $levels = E_ALL, ?int $throwAt = E_ALL, bool $scream = true, $fileLinkFormat = null, bool $scope = true, string $charset = null)
|
||||||
{
|
{
|
||||||
$this->exceptionHandler = $exceptionHandler;
|
$this->exceptionHandler = $exceptionHandler;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
|
@ -60,6 +64,7 @@ class DebugHandlersListener implements EventSubscriberInterface
|
||||||
$this->scream = $scream;
|
$this->scream = $scream;
|
||||||
$this->fileLinkFormat = $fileLinkFormat;
|
$this->fileLinkFormat = $fileLinkFormat;
|
||||||
$this->scope = $scope;
|
$this->scope = $scope;
|
||||||
|
$this->charset = $charset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -146,6 +151,26 @@ class DebugHandlersListener implements EventSubscriberInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
public function onKernelException(GetResponseForExceptionEvent $event)
|
||||||
|
{
|
||||||
|
if (!$this->hasTerminatedWithException || !$event->isMasterRequest()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$debug = $this->scream && $this->scope;
|
||||||
|
$controller = function (Request $request) use ($debug) {
|
||||||
|
$e = $request->attributes->get('exception');
|
||||||
|
$handler = new ExceptionHandler($debug, $this->charset, $this->fileLinkFormat);
|
||||||
|
|
||||||
|
return new Response($handler->getHtml($e), $e->getStatusCode(), $e->getHeaders());
|
||||||
|
};
|
||||||
|
|
||||||
|
(new ExceptionListener($controller, $this->logger, $debug))->onKernelException($event);
|
||||||
|
}
|
||||||
|
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents()
|
||||||
{
|
{
|
||||||
$events = [KernelEvents::REQUEST => ['configure', 2048]];
|
$events = [KernelEvents::REQUEST => ['configure', 2048]];
|
||||||
|
@ -154,6 +179,8 @@ class DebugHandlersListener implements EventSubscriberInterface
|
||||||
$events[ConsoleEvents::COMMAND] = ['configure', 2048];
|
$events[ConsoleEvents::COMMAND] = ['configure', 2048];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$events[KernelEvents::EXCEPTION] = ['onKernelException', -2048];
|
||||||
|
|
||||||
return $events;
|
return $events;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ namespace Symfony\Component\HttpKernel\EventListener;
|
||||||
|
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\Debug\Exception\FlattenException;
|
use Symfony\Component\Debug\Exception\FlattenException;
|
||||||
use Symfony\Component\Debug\ExceptionHandler;
|
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
@ -34,17 +33,12 @@ class ExceptionListener implements EventSubscriberInterface
|
||||||
protected $controller;
|
protected $controller;
|
||||||
protected $logger;
|
protected $logger;
|
||||||
protected $debug;
|
protected $debug;
|
||||||
private $charset;
|
|
||||||
private $fileLinkFormat;
|
|
||||||
private $isTerminating = false;
|
|
||||||
|
|
||||||
public function __construct($controller, LoggerInterface $logger = null, $debug = false, string $charset = null, $fileLinkFormat = null)
|
public function __construct($controller, LoggerInterface $logger = null, $debug = false)
|
||||||
{
|
{
|
||||||
$this->controller = $controller;
|
$this->controller = $controller;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->debug = $debug;
|
$this->debug = $debug;
|
||||||
$this->charset = $charset;
|
|
||||||
$this->fileLinkFormat = $fileLinkFormat;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logKernelException(GetResponseForExceptionEvent $event)
|
public function logKernelException(GetResponseForExceptionEvent $event)
|
||||||
|
@ -61,16 +55,9 @@ class ExceptionListener implements EventSubscriberInterface
|
||||||
public function onKernelException(GetResponseForExceptionEvent $event)
|
public function onKernelException(GetResponseForExceptionEvent $event)
|
||||||
{
|
{
|
||||||
if (null === $this->controller) {
|
if (null === $this->controller) {
|
||||||
if (!$event->isMasterRequest()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$this->isTerminating) {
|
|
||||||
$this->isTerminating = true;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$this->isTerminating = false;
|
|
||||||
}
|
|
||||||
$exception = $event->getException();
|
$exception = $event->getException();
|
||||||
$request = $this->duplicateRequest($exception, $event->getRequest());
|
$request = $this->duplicateRequest($exception, $event->getRequest());
|
||||||
$eventDispatcher = \func_num_args() > 2 ? func_get_arg(2) : null;
|
$eventDispatcher = \func_num_args() > 2 ? func_get_arg(2) : null;
|
||||||
|
@ -107,11 +94,6 @@ class ExceptionListener implements EventSubscriberInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reset()
|
|
||||||
{
|
|
||||||
$this->isTerminating = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getSubscribedEvents()
|
public static function getSubscribedEvents()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -150,12 +132,8 @@ class ExceptionListener implements EventSubscriberInterface
|
||||||
protected function duplicateRequest(\Exception $exception, Request $request)
|
protected function duplicateRequest(\Exception $exception, Request $request)
|
||||||
{
|
{
|
||||||
$attributes = [
|
$attributes = [
|
||||||
'exception' => $exception = FlattenException::create($exception),
|
'_controller' => $this->controller,
|
||||||
'_controller' => $this->controller ?: function () use ($exception) {
|
'exception' => FlattenException::create($exception),
|
||||||
$handler = new ExceptionHandler($this->debug, $this->charset, $this->fileLinkFormat);
|
|
||||||
|
|
||||||
return new Response($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders());
|
|
||||||
},
|
|
||||||
'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null,
|
'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null,
|
||||||
];
|
];
|
||||||
$request = $request->duplicate(null, null, $attributes);
|
$request = $request->duplicate(null, null, $attributes);
|
||||||
|
|
|
@ -104,6 +104,7 @@ class DebugHandlersListenerTest extends TestCase
|
||||||
$xListeners = [
|
$xListeners = [
|
||||||
KernelEvents::REQUEST => [[$listener, 'configure']],
|
KernelEvents::REQUEST => [[$listener, 'configure']],
|
||||||
ConsoleEvents::COMMAND => [[$listener, 'configure']],
|
ConsoleEvents::COMMAND => [[$listener, 'configure']],
|
||||||
|
KernelEvents::EXCEPTION => [[$listener, 'onKernelException']],
|
||||||
];
|
];
|
||||||
$this->assertSame($xListeners, $dispatcher->getListeners());
|
$this->assertSame($xListeners, $dispatcher->getListeners());
|
||||||
|
|
||||||
|
|
|
@ -155,25 +155,6 @@ class ExceptionListenerTest extends TestCase
|
||||||
$this->assertFalse($response->headers->has('content-security-policy'), 'CSP header has been removed');
|
$this->assertFalse($response->headers->has('content-security-policy'), 'CSP header has been removed');
|
||||||
$this->assertFalse($dispatcher->hasListeners(KernelEvents::RESPONSE), 'CSP removal listener has been removed');
|
$this->assertFalse($dispatcher->hasListeners(KernelEvents::RESPONSE), 'CSP removal listener has been removed');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNullController()
|
|
||||||
{
|
|
||||||
$listener = new ExceptionListener(null);
|
|
||||||
$kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
|
|
||||||
$kernel->expects($this->once())->method('handle')->willReturnCallback(function (Request $request) {
|
|
||||||
$controller = $request->attributes->get('_controller');
|
|
||||||
|
|
||||||
return $controller();
|
|
||||||
});
|
|
||||||
$request = Request::create('/');
|
|
||||||
$event = new ExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo'));
|
|
||||||
|
|
||||||
$listener->onKernelException($event);
|
|
||||||
$this->assertNull($event->getResponse());
|
|
||||||
|
|
||||||
$listener->onKernelException($event);
|
|
||||||
$this->assertContains('Whoops, looks like something went wrong.', $event->getResponse()->getContent());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestLogger extends Logger implements DebugLoggerInterface
|
class TestLogger extends Logger implements DebugLoggerInterface
|
||||||
|
|
|
@ -44,7 +44,10 @@ class X509AuthenticationListener extends AbstractPreAuthenticatedListener
|
||||||
$user = null;
|
$user = null;
|
||||||
if ($request->server->has($this->userKey)) {
|
if ($request->server->has($this->userKey)) {
|
||||||
$user = $request->server->get($this->userKey);
|
$user = $request->server->get($this->userKey);
|
||||||
} elseif ($request->server->has($this->credentialKey) && preg_match('#/emailAddress=(.+\@.+\..+)(/|$)#', $request->server->get($this->credentialKey), $matches)) {
|
} elseif (
|
||||||
|
$request->server->has($this->credentialKey)
|
||||||
|
&& preg_match('#emailAddress=(.+\@.+\.[^,/]+)($|,|/)#', $request->server->get($this->credentialKey), $matches)
|
||||||
|
) {
|
||||||
$user = $matches[1];
|
$user = $matches[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,9 +56,8 @@ class X509AuthenticationListenerTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* @dataProvider dataProviderGetPreAuthenticatedDataNoUser
|
* @dataProvider dataProviderGetPreAuthenticatedDataNoUser
|
||||||
*/
|
*/
|
||||||
public function testGetPreAuthenticatedDataNoUser($emailAddress)
|
public function testGetPreAuthenticatedDataNoUser($emailAddress, $credentials)
|
||||||
{
|
{
|
||||||
$credentials = 'CN=Sample certificate DN/emailAddress='.$emailAddress;
|
|
||||||
$request = new Request([], [], [], [], [], ['SSL_CLIENT_S_DN' => $credentials]);
|
$request = new Request([], [], [], [], [], ['SSL_CLIENT_S_DN' => $credentials]);
|
||||||
|
|
||||||
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
|
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
|
||||||
|
@ -76,10 +75,12 @@ class X509AuthenticationListenerTest extends TestCase
|
||||||
|
|
||||||
public static function dataProviderGetPreAuthenticatedDataNoUser()
|
public static function dataProviderGetPreAuthenticatedDataNoUser()
|
||||||
{
|
{
|
||||||
return [
|
yield ['cert@example.com', 'CN=Sample certificate DN/emailAddress=cert@example.com'];
|
||||||
'basicEmailAddress' => ['cert@example.com'],
|
yield ['cert+something@example.com', 'CN=Sample certificate DN/emailAddress=cert+something@example.com'];
|
||||||
'emailAddressWithPlusSign' => ['cert+something@example.com'],
|
yield ['cert@example.com', 'CN=Sample certificate DN,emailAddress=cert@example.com'];
|
||||||
];
|
yield ['cert+something@example.com', 'CN=Sample certificate DN,emailAddress=cert+something@example.com'];
|
||||||
|
yield ['cert+something@example.com', 'emailAddress=cert+something@example.com,CN=Sample certificate DN'];
|
||||||
|
yield ['cert+something@example.com', 'emailAddress=cert+something@example.com'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -92,7 +92,15 @@ class JsonDecode implements DecoderInterface
|
||||||
$recursionDepth = $context[self::RECURSION_DEPTH] ?? $this->defaultContext[self::RECURSION_DEPTH];
|
$recursionDepth = $context[self::RECURSION_DEPTH] ?? $this->defaultContext[self::RECURSION_DEPTH];
|
||||||
$options = $context[self::OPTIONS] ?? $this->defaultContext[self::OPTIONS];
|
$options = $context[self::OPTIONS] ?? $this->defaultContext[self::OPTIONS];
|
||||||
|
|
||||||
|
try {
|
||||||
$decodedData = json_decode($data, $associative, $recursionDepth, $options);
|
$decodedData = json_decode($data, $associative, $recursionDepth, $options);
|
||||||
|
} catch (\JsonException $e) {
|
||||||
|
throw new NotEncodableValueException($e->getMessage(), 0, $e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $options)) {
|
||||||
|
return $decodedData;
|
||||||
|
}
|
||||||
|
|
||||||
if (JSON_ERROR_NONE !== json_last_error()) {
|
if (JSON_ERROR_NONE !== json_last_error()) {
|
||||||
throw new NotEncodableValueException(json_last_error_msg());
|
throw new NotEncodableValueException(json_last_error_msg());
|
||||||
|
|
|
@ -50,6 +50,10 @@ class JsonEncode implements EncoderInterface
|
||||||
$jsonEncodeOptions = $context[self::OPTIONS] ?? $this->defaultContext[self::OPTIONS];
|
$jsonEncodeOptions = $context[self::OPTIONS] ?? $this->defaultContext[self::OPTIONS];
|
||||||
$encodedJson = json_encode($data, $jsonEncodeOptions);
|
$encodedJson = json_encode($data, $jsonEncodeOptions);
|
||||||
|
|
||||||
|
if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $jsonEncodeOptions)) {
|
||||||
|
return $encodedJson;
|
||||||
|
}
|
||||||
|
|
||||||
if (JSON_ERROR_NONE !== json_last_error() && (false === $encodedJson || !($jsonEncodeOptions & JSON_PARTIAL_OUTPUT_ON_ERROR))) {
|
if (JSON_ERROR_NONE !== json_last_error() && (false === $encodedJson || !($jsonEncodeOptions & JSON_PARTIAL_OUTPUT_ON_ERROR))) {
|
||||||
throw new NotEncodableValueException(json_last_error_msg());
|
throw new NotEncodableValueException(json_last_error_msg());
|
||||||
}
|
}
|
||||||
|
|
|
@ -495,6 +495,16 @@ abstract class HttpClientTestCase extends TestCase
|
||||||
$this->assertSame(['foo' => '0123456789', 'REQUEST_METHOD' => 'POST'], $response->toArray());
|
$this->assertSame(['foo' => '0123456789', 'REQUEST_METHOD' => 'POST'], $response->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCancel()
|
||||||
|
{
|
||||||
|
$client = $this->getHttpClient(__FUNCTION__);
|
||||||
|
$response = $client->request('GET', 'http://localhost:8057/timeout-header');
|
||||||
|
|
||||||
|
$response->cancel();
|
||||||
|
$this->expectException(TransportExceptionInterface::class);
|
||||||
|
$response->getHeaders();
|
||||||
|
}
|
||||||
|
|
||||||
public function testOnProgressCancel()
|
public function testOnProgressCancel()
|
||||||
{
|
{
|
||||||
$client = $this->getHttpClient(__FUNCTION__);
|
$client = $this->getHttpClient(__FUNCTION__);
|
||||||
|
|
Reference in New Issue