diff --git a/CHANGELOG-4.0.md b/CHANGELOG-4.0.md index d055c43f1435d..cbd0ed892c1db 100644 --- a/CHANGELOG-4.0.md +++ b/CHANGELOG-4.0.md @@ -7,6 +7,16 @@ in 4.0 minor versions. To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v4.0.0...v4.0.1 +* 4.0.8 (2018-04-06) + + * bug #26802 [Security] register custom providers on ExpressionLanguage directly (dmaicher) + * bug #26794 [PhpUnitBridge] Catch deprecation error handler (cvilleger) + * bug #26788 [Security] Load the user before pre/post auth checks when needed (chalasr) + * bug #26792 [Routing] Fix throwing NoConfigurationException instead of 405 (nicolas-grekas) + * bug #26774 [SecurityBundle] Add missing argument to security.authentication.provider.simple (i3or1s, chalasr) + * bug #26763 [Finder] Remove duplicate slashes in filenames (helhum) + * bug #26758 [WebProfilerBundle][HttpKernel] Make FileLinkFormatter URL format generation lazy (nicolas-grekas) + * 4.0.7 (2018-04-03) * bug #26387 [Yaml] Fix regression when trying to parse multiline (antograssiot) diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index 4a6d02b37440b..14dc6f07a6f8d 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -368,7 +368,7 @@ Form ```php class MyTimezoneType extends TimezoneType { - public function loadChoices() + public function loadChoiceList() { // override the method } diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index e14d218708c77..22992da68051e 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -118,7 +118,7 @@ public static function register($mode = 0) } if (isset($trace[$i]['object']) || isset($trace[$i]['class'])) { - if (isset($trace[$i]['class']) && in_array($trace[$i]['class'], array('Symfony\Bridge\PhpUnit\SymfonyTestsListener', 'Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListener'), true)) { + if (isset($trace[$i]['class']) && 0 === strpos($trace[$i]['class'], 'Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerFor')) { $parsedMsg = unserialize($msg); $msg = $parsedMsg['deprecation']; $class = $parsedMsg['class']; @@ -216,7 +216,7 @@ public static function register($mode = 0) $groups = array('unsilenced', 'remaining'); if (DeprecationErrorHandler::MODE_WEAK_VENDORS === $mode) { - $groups[] = 'remaining vendor'; + $groups[] = 'remaining vendor'; } array_push($groups, 'legacy', 'other'); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddExpressionLanguageProvidersPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddExpressionLanguageProvidersPass.php index d4103d8dff1a1..bceacd21ea91b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddExpressionLanguageProvidersPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddExpressionLanguageProvidersPass.php @@ -36,10 +36,10 @@ public function process(ContainerBuilder $container) } // security - if ($container->has('security.access.expression_voter')) { - $definition = $container->findDefinition('security.access.expression_voter'); + if ($container->has('security.expression_language')) { + $definition = $container->findDefinition('security.expression_language'); foreach ($container->findTaggedServiceIds('security.expression_language_provider', true) as $id => $attributes) { - $definition->addMethodCall('addExpressionLanguageProvider', array(new Reference($id))); + $definition->addMethodCall('registerProvider', array(new Reference($id))); } } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddExpressionLanguageProvidersPassTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddExpressionLanguageProvidersPassTest.php index d2fa0f4bdfb69..89ba5ff73076a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddExpressionLanguageProvidersPassTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddExpressionLanguageProvidersPassTest.php @@ -24,7 +24,7 @@ public function testProcessForRouter() $container = new ContainerBuilder(); $container->addCompilerPass(new AddExpressionLanguageProvidersPass()); - $definition = new Definition('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TestProvider'); + $definition = new Definition('\stdClass'); $definition->addTag('routing.expression_language_provider'); $container->setDefinition('some_routing_provider', $definition->setPublic(true)); @@ -43,7 +43,7 @@ public function testProcessForRouterAlias() $container = new ContainerBuilder(); $container->addCompilerPass(new AddExpressionLanguageProvidersPass()); - $definition = new Definition('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TestProvider'); + $definition = new Definition('\stdClass'); $definition->addTag('routing.expression_language_provider'); $container->setDefinition('some_routing_provider', $definition->setPublic(true)); @@ -63,17 +63,16 @@ public function testProcessForSecurity() $container = new ContainerBuilder(); $container->addCompilerPass(new AddExpressionLanguageProvidersPass()); - $definition = new Definition('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TestProvider'); + $definition = new Definition('\stdClass'); $definition->addTag('security.expression_language_provider'); $container->setDefinition('some_security_provider', $definition->setPublic(true)); - $container->register('security.access.expression_voter', '\stdClass')->setPublic(true); + $container->register('security.expression_language', '\stdClass')->setPublic(true); $container->compile(); - $router = $container->getDefinition('security.access.expression_voter'); - $calls = $router->getMethodCalls(); + $calls = $container->getDefinition('security.expression_language')->getMethodCalls(); $this->assertCount(1, $calls); - $this->assertEquals('addExpressionLanguageProvider', $calls[0][0]); + $this->assertEquals('registerProvider', $calls[0][0]); $this->assertEquals(new Reference('some_security_provider'), $calls[0][1][0]); } @@ -82,22 +81,17 @@ public function testProcessForSecurityAlias() $container = new ContainerBuilder(); $container->addCompilerPass(new AddExpressionLanguageProvidersPass()); - $definition = new Definition('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler\TestProvider'); + $definition = new Definition('\stdClass'); $definition->addTag('security.expression_language_provider'); $container->setDefinition('some_security_provider', $definition->setPublic(true)); - $container->register('my_security.access.expression_voter', '\stdClass')->setPublic(true); - $container->setAlias('security.access.expression_voter', 'my_security.access.expression_voter'); + $container->register('my_security.expression_language', '\stdClass')->setPublic(true); + $container->setAlias('security.expression_language', 'my_security.expression_language'); $container->compile(); - $router = $container->getDefinition('my_security.access.expression_voter'); - $calls = $router->getMethodCalls(); + $calls = $container->getDefinition('my_security.expression_language')->getMethodCalls(); $this->assertCount(1, $calls); - $this->assertEquals('addExpressionLanguageProvider', $calls[0][0]); + $this->assertEquals('registerProvider', $calls[0][0]); $this->assertEquals(new Reference('some_security_provider'), $calls[0][1][0]); } } - -class TestProvider -{ -} diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php index 39bcf4dadab38..d18d2a92f06fb 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/GuardAuthenticationFactory.php @@ -119,7 +119,7 @@ private function determineEntryPoint($defaultEntryPointId, array $config) // we have multiple entry points - we must ask them to configure one throw new \LogicException(sprintf( - 'Because you have multiple guard configurators, you need to set the "guard.entry_point" key to one of you configurators (%s)', + 'Because you have multiple guard configurators, you need to set the "guard.entry_point" key to one of your configurators (%s)', implode(', ', $authenticatorIds) )); } diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimplePreAuthenticationFactory.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimplePreAuthenticationFactory.php index b1304a55b3f87..5e394fca67c7b 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimplePreAuthenticationFactory.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimplePreAuthenticationFactory.php @@ -49,6 +49,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider, ->replaceArgument(0, new Reference($config['authenticator'])) ->replaceArgument(1, new Reference($userProvider)) ->replaceArgument(2, $id) + ->replaceArgument(3, new Reference('security.user_checker.'.$id)) ; // listener diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml index 5d57c69e8e9ce..d87e2287fda02 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security_listeners.xml @@ -199,6 +199,7 @@ + null diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php index cedc5dfa06a2e..c1791beaf5fbf 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php @@ -148,6 +148,23 @@ public function testFirewalls() ), null, ), + array( + 'simple_auth', + 'security.user_checker', + null, + true, + false, + 'security.user.provider.concrete.default', + 'simple_auth', + 'security.authentication.form_entry_point.simple_auth', + null, + null, + array( + 'simple_form', + 'anonymous', + ), + null, + ), ), $configs); $this->assertEquals(array( @@ -178,6 +195,13 @@ public function testFirewalls() 'security.authentication.listener.anonymous.with_user_checker', 'security.access_listener', ), + array( + 'security.channel_listener', + 'security.context_listener.2', + 'security.authentication.listener.simple_form.simple_auth', + 'security.authentication.listener.anonymous.simple_auth', + 'security.access_listener', + ), ), $listeners); $this->assertFalse($container->hasAlias('Symfony\Component\Security\Core\User\UserCheckerInterface', 'No user checker alias is registered when custom user checker services are registered')); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php index 7290676a2bfc7..c8c1373609e7b 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/php/container1.php @@ -90,6 +90,12 @@ 'http_basic' => true, 'logout_on_user_change' => true, ), + 'simple_auth' => array( + 'provider' => 'default', + 'anonymous' => true, + 'simple_form' => array('authenticator' => 'simple_authenticator'), + 'logout_on_user_change' => true, + ), ), 'access_control' => array( diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml index 1f317ac2d2697..4c8a41d6695f0 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/xml/container1.xml @@ -68,6 +68,11 @@ app.user_checker + + + + + ROLE_USER ROLE_USER,ROLE_ADMIN,ROLE_ALLOWED_TO_SWITCH ROLE_USER,ROLE_ADMIN diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/container1.yml b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/container1.yml index ad90e433be796..674e341a174b6 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/container1.yml +++ b/src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/Fixtures/yml/container1.yml @@ -73,6 +73,12 @@ security: user_checker: app.user_checker logout_on_user_change: true + simple_auth: + provider: default + anonymous: ~ + simple_form: { authenticator: simple_authenticator } + logout_on_user_change: true + role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] diff --git a/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php b/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php index 8f74d05f43d05..c4c9e0a37bf83 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php +++ b/src/Symfony/Bundle/WebProfilerBundle/DependencyInjection/WebProfilerExtension.php @@ -11,10 +11,13 @@ namespace Symfony\Bundle\WebProfilerBundle\DependencyInjection; +use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Config\FileLocator; +use Symfony\Component\HttpKernel\Kernel; use Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener; /** @@ -51,6 +54,11 @@ public function load(array $configs, ContainerBuilder $container) $container->setParameter('web_profiler.debug_toolbar.intercept_redirects', $config['intercept_redirects']); $container->setParameter('web_profiler.debug_toolbar.mode', $config['toolbar'] ? WebDebugToolbarListener::ENABLED : WebDebugToolbarListener::DISABLED); } + + if (Kernel::VERSION_ID >= 40008 || (Kernel::VERSION_ID >= 30408 && Kernel::VERSION_ID < 40000)) { + $container->getDefinition('debug.file_link_formatter') + ->replaceArgument(3, new ServiceClosureArgument(new Reference('debug.file_link_formatter.url_format'))); + } } /** diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/profiler.xml b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/profiler.xml index 165b8ea59770e..8858593fc0810 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/config/profiler.xml +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/config/profiler.xml @@ -55,20 +55,14 @@ %debug.file_link_format% %kernel.project_dir% - - - - - - - - _profiler_open_file - - - ?file=%%f&line=%%l#line%%l - - - + /_profiler/open?file=%%f&line=%%l#line%%l + + + + + + _profiler_open_file + ?file=%%f&line=%%l#line%%l diff --git a/src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php index 9443f21664ced..9997a7b0ec607 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php @@ -158,7 +158,7 @@ public function testStopEventPropagation() // be executed // Manually set priority to enforce $this->listener to be called first $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'), 10); - $this->dispatcher->addListener('post.foo', array($otherListener, 'preFoo')); + $this->dispatcher->addListener('post.foo', array($otherListener, 'postFoo')); $this->dispatcher->dispatch(self::postFoo); $this->assertTrue($this->listener->postFooInvoked); $this->assertFalse($otherListener->postFooInvoked); diff --git a/src/Symfony/Component/Finder/Finder.php b/src/Symfony/Component/Finder/Finder.php index 7cb0853ae78b6..105acc70ce41a 100644 --- a/src/Symfony/Component/Finder/Finder.php +++ b/src/Symfony/Component/Finder/Finder.php @@ -540,9 +540,9 @@ public function in($dirs) foreach ((array) $dirs as $dir) { if (is_dir($dir)) { - $resolvedDirs[] = $dir; + $resolvedDirs[] = $this->normalizeDir($dir); } elseif ($glob = glob($dir, (defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) { - $resolvedDirs = array_merge($resolvedDirs, $glob); + $resolvedDirs = array_merge($resolvedDirs, array_map(array($this, 'normalizeDir'), $glob)); } else { throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir)); } @@ -723,4 +723,16 @@ private function searchInDirectory(string $dir): \Iterator return $iterator; } + + /** + * Normalizes given directory names by removing trailing slashes. + * + * @param string $dir + * + * @return string + */ + private function normalizeDir($dir) + { + return rtrim($dir, '/'.\DIRECTORY_SEPARATOR); + } } diff --git a/src/Symfony/Component/Finder/SplFileInfo.php b/src/Symfony/Component/Finder/SplFileInfo.php index 6800792ecef48..6516113a3ece4 100644 --- a/src/Symfony/Component/Finder/SplFileInfo.php +++ b/src/Symfony/Component/Finder/SplFileInfo.php @@ -28,7 +28,7 @@ class SplFileInfo extends \SplFileInfo */ public function __construct(string $file, string $relativePath, string $relativePathname) { - parent::__construct(realpath($file) ?: $file); + parent::__construct($file); $this->relativePath = $relativePath; $this->relativePathname = $relativePathname; } diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index 634f731a9bc4f..c7908fa86743d 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -48,15 +48,40 @@ public function testFiles() public function testRemoveTrailingSlash() { - if ('\\' === \DIRECTORY_SEPARATOR) { - $this->markTestSkipped('This test cannot be run on Windows.'); + $finder = $this->buildFinder(); + + $expected = $this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar')); + $in = self::$tmpDir.'//'; + + $this->assertIterator($expected, $finder->in($in)->files()->getIterator()); + } + + public function testSymlinksNotResolved() + { + if ('\\' === DIRECTORY_SEPARATOR) { + $this->markTestSkipped('symlinks are not supported on Windows'); } $finder = $this->buildFinder(); - $expected = $this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar')); - $in = '//'.realpath(self::$tmpDir).'//'; + symlink($this->toAbsolute('foo'), $this->toAbsolute('baz')); + $expected = $this->toAbsolute(array('baz/bar.tmp')); + $in = self::$tmpDir.'/baz/'; + try { + $this->assertIterator($expected, $finder->in($in)->files()->getIterator()); + unlink($this->toAbsolute('baz')); + } catch (\Exception $e) { + unlink($this->toAbsolute('baz')); + throw $e; + } + } + + public function testBackPathNotNormalized() + { + $finder = $this->buildFinder(); + $expected = $this->toAbsolute(array('foo/../foo/bar.tmp')); + $in = self::$tmpDir.'/foo/../foo/'; $this->assertIterator($expected, $finder->in($in)->files()->getIterator()); } @@ -275,7 +300,7 @@ public function testInWithNonExistentDirectory() public function testInWithGlob() { $finder = $this->buildFinder(); - $finder->in(array(__DIR__.'/Fixtures/*/B/C', __DIR__.'/Fixtures/*/*/B/C'))->getIterator(); + $finder->in(array(__DIR__.'/Fixtures/*/B/C/', __DIR__.'/Fixtures/*/*/B/C/'))->getIterator(); $this->assertIterator($this->toAbsoluteFixtures(array('A/B/C/abc.dat', 'copy/A/B/C/abc.dat.copy')), $finder); } @@ -528,8 +553,8 @@ public function testMultipleLocationsWithSubDirectories() $finder->in($locations)->depth('< 10')->name('*.neon'); $expected = array( - __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'one'.DIRECTORY_SEPARATOR.'b'.DIRECTORY_SEPARATOR.'c.neon', - __DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'one'.DIRECTORY_SEPARATOR.'b'.DIRECTORY_SEPARATOR.'d.neon', + __DIR__.'/Fixtures/one'.DIRECTORY_SEPARATOR.'b'.DIRECTORY_SEPARATOR.'c.neon', + __DIR__.'/Fixtures/one'.DIRECTORY_SEPARATOR.'b'.DIRECTORY_SEPARATOR.'d.neon', ); $this->assertIterator($expected, $finder); diff --git a/src/Symfony/Component/Form/Resources/translations/validators.da.xlf b/src/Symfony/Component/Form/Resources/translations/validators.da.xlf index c2dd4601f9089..f52f4e0a30db9 100644 --- a/src/Symfony/Component/Form/Resources/translations/validators.da.xlf +++ b/src/Symfony/Component/Form/Resources/translations/validators.da.xlf @@ -8,11 +8,11 @@ The uploaded file was too large. Please try to upload a smaller file. - Den oploadede fil var for stor. Opload venligst en mindre fil. + Den uploadede fil var for stor. Upload venligst en mindre fil. The CSRF token is invalid. Please try to resubmit the form. - CSRF nøglen er ugyldig. + CSRF-token er ugyldig. diff --git a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php index 2f1806689a24c..a4aa6c79ac321 100644 --- a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php +++ b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php @@ -13,6 +13,8 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\Routing\Exception\ExceptionInterface; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** * Formats debug file links. @@ -26,7 +28,10 @@ class FileLinkFormatter implements \Serializable private $baseDir; private $urlFormat; - public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, string $urlFormat = null) + /** + * @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand + */ + public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, $urlFormat = null) { $fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); if ($fileLinkFormat && !is_array($fileLinkFormat)) { @@ -66,6 +71,18 @@ public function unserialize($serialized) $this->fileLinkFormat = unserialize($serialized, array('allowed_classes' => false)); } + /** + * @internal + */ + public static function generateUrlFormat(UrlGeneratorInterface $router, $routeName, $queryString) + { + try { + return $router->generate($routeName).$queryString; + } catch (ExceptionInterface $e) { + return null; + } + } + private function getFileLinkFormat() { if ($this->fileLinkFormat) { @@ -74,6 +91,10 @@ private function getFileLinkFormat() if ($this->requestStack && $this->baseDir && $this->urlFormat) { $request = $this->requestStack->getMasterRequest(); if ($request instanceof Request) { + if ($this->urlFormat instanceof \Closure && !$this->urlFormat = \call_user_func($this->urlFormat)) { + return; + } + return array( $request->getSchemeAndHttpHost().$request->getBaseUrl().$this->urlFormat, $this->baseDir.DIRECTORY_SEPARATOR, '', diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 883d7c9eaf476..db80323c206d9 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -63,11 +63,11 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl private $requestStackSize = 0; private $resetServices = false; - const VERSION = '4.0.7'; - const VERSION_ID = 40007; + const VERSION = '4.0.8'; + const VERSION_ID = 40008; const MAJOR_VERSION = 4; const MINOR_VERSION = 0; - const RELEASE_VERSION = 7; + const RELEASE_VERSION = 8; const EXTRA_VERSION = ''; const END_OF_MAINTENANCE = '07/2018'; diff --git a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php index d3c931dd3fd29..40d8df67ed6e1 100644 --- a/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php +++ b/src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php @@ -154,7 +154,7 @@ private function compileRoutes(RouteCollection $routes, $supportsRedirections) } // used to display the Welcome Page in apps that don't define a homepage - $code .= " if ('/' === \$pathinfo) {\n"; + $code .= " if ('/' === \$pathinfo && !\$allow) {\n"; $code .= " throw new Symfony\Component\Routing\Exception\NoConfigurationException();\n"; $code .= " }\n"; @@ -362,7 +362,7 @@ private function compileRoute(Route $route, $name, $supportsRedirections, $paren EOF; } } elseif ($methods) { - $code .= <<allow) { throw new NoConfigurationException(); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher0.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher0.php index 59253f0749da7..9e9b9103bf77e 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher0.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher0.php @@ -28,7 +28,7 @@ public function match($rawPathinfo) $canonicalMethod = 'GET'; } - if ('/' === $pathinfo) { + if ('/' === $pathinfo && !$allow) { throw new Symfony\Component\Routing\Exception\NoConfigurationException(); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php index 4ea0757e714fb..23a93c193423d 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher1.php @@ -309,7 +309,7 @@ public function match($rawPathinfo) } - if ('/' === $pathinfo) { + if ('/' === $pathinfo && !$allow) { throw new Symfony\Component\Routing\Exception\NoConfigurationException(); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php index 8d1c27d7c1441..e430adb1fba6c 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher2.php @@ -371,7 +371,7 @@ public function match($rawPathinfo) } not_nonsecure: - if ('/' === $pathinfo) { + if ('/' === $pathinfo && !$allow) { throw new Symfony\Component\Routing\Exception\NoConfigurationException(); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php index 375b56cafa4c5..67c4667467e6f 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher3.php @@ -46,7 +46,7 @@ public function match($rawPathinfo) return array('_route' => 'with-condition'); } - if ('/' === $pathinfo) { + if ('/' === $pathinfo && !$allow) { throw new Symfony\Component\Routing\Exception\NoConfigurationException(); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher4.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher4.php index c3ca977544ff1..ed07194a260ec 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher4.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher4.php @@ -103,7 +103,7 @@ public function match($rawPathinfo) } - if ('/' === $pathinfo) { + if ('/' === $pathinfo && !$allow) { throw new Symfony\Component\Routing\Exception\NoConfigurationException(); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher5.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher5.php index 3a6faea20bc47..2b22513a6179d 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher5.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher5.php @@ -200,7 +200,7 @@ public function match($rawPathinfo) } - if ('/' === $pathinfo) { + if ('/' === $pathinfo && !$allow) { throw new Symfony\Component\Routing\Exception\NoConfigurationException(); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher6.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher6.php index 415c328d33c4b..48ecdf81c001d 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher6.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher6.php @@ -204,7 +204,7 @@ public function match($rawPathinfo) } - if ('/' === $pathinfo) { + if ('/' === $pathinfo && !$allow) { throw new Symfony\Component\Routing\Exception\NoConfigurationException(); } diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher7.php b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher7.php index bbf6cf6e0bcd8..81d76ea4a047a 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher7.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/dumper/url_matcher7.php @@ -240,7 +240,7 @@ public function match($rawPathinfo) } - if ('/' === $pathinfo) { + if ('/' === $pathinfo && !$allow) { throw new Symfony\Component\Routing\Exception\NoConfigurationException(); } diff --git a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php index 1bd75fa339c21..e8d31e2225298 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/UrlMatcherTest.php @@ -45,6 +45,21 @@ public function testMethodNotAllowed() } } + public function testMethodNotAllowedOnRoot() + { + $coll = new RouteCollection(); + $coll->add('foo', new Route('/', array(), array(), array(), '', array(), array('GET'))); + + $matcher = $this->getUrlMatcher($coll, new RequestContext('', 'POST')); + + try { + $matcher->match('/'); + $this->fail(); + } catch (MethodNotAllowedException $e) { + $this->assertEquals(array('GET'), $e->getAllowedMethods()); + } + } + public function testHeadAllowedWhenRequirementContainsGet() { $coll = new RouteCollection(); diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php index 0c16c96aeb334..e27ad368ab8c2 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php @@ -11,8 +11,11 @@ namespace Symfony\Component\Security\Core\Authentication\Provider; +use Symfony\Component\Security\Core\Exception\AuthenticationServiceException; +use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; use Symfony\Component\Security\Core\User\UserChecker; use Symfony\Component\Security\Core\User\UserCheckerInterface; +use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserProviderInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface; @@ -45,6 +48,24 @@ public function authenticate(TokenInterface $token) } $user = $authToken->getUser(); + + if (!$user instanceof UserInterface) { + try { + $user = $this->userProvider->loadUserByUsername($user); + + if (!$user instanceof UserInterface) { + throw new AuthenticationServiceException('The user provider must return a UserInterface object.'); + } + } catch (UsernameNotFoundException $e) { + $e->setUsername($user); + throw $e; + } catch (\Exception $e) { + $e = new AuthenticationServiceException($e->getMessage(), 0, $e); + $e->setToken($token); + throw $e; + } + } + $this->userChecker->checkPreAuth($user); $this->userChecker->checkPostAuth($user); diff --git a/src/Symfony/Component/Security/Core/Resources/translations/security.da.xlf b/src/Symfony/Component/Security/Core/Resources/translations/security.da.xlf index 102c8f1179521..183ebe83e71dd 100644 --- a/src/Symfony/Component/Security/Core/Resources/translations/security.da.xlf +++ b/src/Symfony/Component/Security/Core/Resources/translations/security.da.xlf @@ -24,11 +24,11 @@ Not privileged to request the resource. - Ingen tilladselese at anvende kilden. + Ingen adgang til at forespørge ressourcen. Invalid CSRF token. - Ugyldigt CSRF token. + Ugyldig CSRF-token. No authentication provider found to support the authentication token. diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php index 1e7069c1fa0bb..acee33b856b42 100644 --- a/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php @@ -15,6 +15,7 @@ use Symfony\Component\Security\Core\Exception\DisabledException; use Symfony\Component\Security\Core\Authentication\Provider\SimpleAuthenticationProvider; use Symfony\Component\Security\Core\Exception\LockedException; +use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; class SimpleAuthenticationProviderTest extends TestCase { @@ -72,6 +73,54 @@ public function testAuthenticateWhenPostChecksFails() $provider->authenticate($token); } + public function testAuthenticateFromString() + { + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token->expects($this->any()) + ->method('getUser') + ->will($this->returnValue('foo')); + + $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); + $authenticator->expects($this->once()) + ->method('authenticateToken') + ->will($this->returnValue($token)); + + $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); + $userProvider->expects($this->once()) + ->method('loadUserByUsername') + ->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock()); + $provider = $this->getProvider($authenticator, $userProvider); + + $this->assertSame($token, $provider->authenticate($token)); + } + + /** + * @expectedException \Symfony\Component\Security\Core\Exception\UsernameNotFoundException + */ + public function testUsernameNotFound() + { + $user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); + + $token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); + $token->expects($this->any()) + ->method('getUser') + ->will($this->returnValue('foo')); + + $authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock(); + $authenticator->expects($this->once()) + ->method('authenticateToken') + ->will($this->returnValue($token)); + + $userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock(); + $userProvider->expects($this->once()) + ->method('loadUserByUsername') + ->willThrowException(new UsernameNotFoundException()); + + $this->getProvider($authenticator, $userProvider)->authenticate($token); + } + protected function getProvider($simpleAuthenticator = null, $userProvider = null, $userChecker = null, $key = 'test') { if (null === $userChecker) { diff --git a/src/Symfony/Component/Validator/Resources/translations/validators.da.xlf b/src/Symfony/Component/Validator/Resources/translations/validators.da.xlf index 4f8556a3c17a0..3a545c80b6409 100644 --- a/src/Symfony/Component/Validator/Resources/translations/validators.da.xlf +++ b/src/Symfony/Component/Validator/Resources/translations/validators.da.xlf @@ -20,19 +20,19 @@ The value you selected is not a valid choice. - Værdien skal være en af de givne muligheder. + Den valgte værdi er ikke gyldig. You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices. - Du skal vælge mindst {{ limit }} muligheder. + Du skal vælge mindst én mulighed.|Du skal vælge mindst {{ limit }} muligheder. You must select at most {{ limit }} choice.|You must select at most {{ limit }} choices. - Du kan højest vælge {{ limit }} muligheder. + Du kan højst vælge én mulighed.|Du kan højst vælge {{ limit }} muligheder. One or more of the given values is invalid. - En eller flere af de oplyste værdier er ugyldige. + En eller flere af de angivne værdier er ugyldige. This field was not expected. @@ -40,7 +40,7 @@ This field is missing. - Dette felt er mangler. + Dette felt mangler. This value is not a valid date. @@ -48,11 +48,11 @@ This value is not a valid datetime. - Værdien er ikke en gyldig dato og tid. + Værdien er ikke et gyldigt tidspunkt. This value is not a valid email address. - Værdien er ikke en gyldig e-mail adresse. + Værdien er ikke en gyldig e-mailadresse. The file could not be found. @@ -64,11 +64,11 @@ The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}. - Filen er for stor ({{ size }} {{ suffix }}). Tilladte maksimale størrelse {{ limit }} {{ suffix }}. + Filen er for stor ({{ size }} {{ suffix }}). Maksimale tilladte størrelse er {{ limit }} {{ suffix }}. The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}. - Mimetypen af filen er ugyldig ({{ type }}). Tilladte mimetyper er {{ types }}. + Filens MIME-type er ugyldig ({{ type }}). Tilladte MIME-typer er {{ types }}. This value should be {{ limit }} or less. @@ -76,7 +76,7 @@ This value is too long. It should have {{ limit }} character or less.|This value is too long. It should have {{ limit }} characters or less. - Værdien er for lang. Den skal have {{ limit }} bogstaver eller mindre. + Værdien er for lang. Den må højst indeholde {{ limit }} tegn. This value should be {{ limit }} or more. @@ -84,7 +84,7 @@ This value is too short. It should have {{ limit }} character or more.|This value is too short. It should have {{ limit }} characters or more. - Værdien er for kort. Den skal have {{ limit }} tegn eller flere. + Værdien er for kort. Den skal indeholde mindst {{ limit }} tegn. This value should not be blank. @@ -104,7 +104,7 @@ This value is not a valid time. - Værdien er ikke en gyldig tid. + Værdien er ikke et gyldigt klokkeslæt. This value is not a valid URL. @@ -136,7 +136,7 @@ This is not a valid IP address. - Dette er ikke en gyldig IP adresse. + Dette er ikke en gyldig IP-adresse. This value is not a valid language. @@ -160,31 +160,31 @@ The image width is too big ({{ width }}px). Allowed maximum width is {{ max_width }}px. - Billedbredden er for stor ({{ width }}px). Tilladt maksimumsbredde er {{ max_width }}px. + Billedet er for bredt ({{ width }}px). Største tilladte bredde er {{ max_width }}px. The image width is too small ({{ width }}px). Minimum width expected is {{ min_width }}px. - Billedebredden er for lille ({{ width }}px). Forventet minimumshøjde er {{ min_width }}px. + Billedet er for smalt ({{ width }}px). Mindste forventede bredde er {{ min_width }}px. The image height is too big ({{ height }}px). Allowed maximum height is {{ max_height }}px. - Billedhøjden er for stor ({{ height }}px). Tilladt maksimumshøjde er {{ max_height }}px. + Billedet er for højt ({{ height }}px). Største tilladte højde er {{ max_height }}px. The image height is too small ({{ height }}px). Minimum height expected is {{ min_height }}px. - Billedhøjden er for lille ({{ height }}px). Forventet minimumshøjde er {{ min_height }}px. + Billedet er for lavt ({{ height }}px). Mindste forventede højde er {{ min_height }}px. This value should be the user's current password. - Værdien skal være brugerens nuværende password. + Værdien skal være brugerens nuværende adgangskode. This value should have exactly {{ limit }} character.|This value should have exactly {{ limit }} characters. - Værdien skal have præcis {{ limit }} tegn. + Værdien skal være på præcis {{ limit }} tegn. The file was only partially uploaded. - Filen var kun delvis uploadet. + Filen blev kun delvist uploadet. No file was uploaded. @@ -200,19 +200,19 @@ A PHP extension caused the upload to fail. - En PHP udvidelse forårsagede fejl i upload. + En PHP-udvidelse forårsagede fejl i upload. This collection should contain {{ limit }} element or more.|This collection should contain {{ limit }} elements or more. - Denne samling skal indeholde {{ limit }} element eller flere.|Denne samling skal indeholde {{ limit }} elementer eller flere. + Denne samling skal indeholde mindst ét element.|Denne samling skal indeholde mindst {{ limit }} elementer. This collection should contain {{ limit }} element or less.|This collection should contain {{ limit }} elements or less. - Denne samling skal indeholde {{ limit }} element eller mindre.|Denne samling skal indeholde {{ limit }} elementer eller mindre. + Denne samling skal indeholde højst ét element.|Denne samling skal indeholde højst {{ limit }} elementer. This collection should contain exactly {{ limit }} element.|This collection should contain exactly {{ limit }} elements. - Denne samling skal indeholde præcis {{ limit }} element.|Denne samling skal indeholde præcis {{ limit }} elementer. + Denne samling skal indeholde præcis ét element.|Denne samling skal indeholde præcis {{ limit }} elementer. Invalid card number. @@ -224,7 +224,7 @@ This is not a valid International Bank Account Number (IBAN). - Det er ikke en gyldig International Bank Account Number (IBAN). + Det er ikke et gyldigt International Bank Account Number (IBAN). This value is not a valid ISBN-10. diff --git a/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php b/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php index 92cf6fb88299c..c9cc24f2dff62 100644 --- a/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Caster/ExceptionCasterTest.php @@ -126,6 +126,10 @@ public function testNoSrcContext() public function testHtmlDump() { + if (ini_get('xdebug.file_link_format') || get_cfg_var('xdebug.file_link_format')) { + $this->markTestSkipped('A custom file_link_format is defined.'); + } + $e = $this->getTestException(1); ExceptionCaster::$srcContext = -1; diff --git a/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php b/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php index 12a7240186910..ac2f8f2c30a14 100644 --- a/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php +++ b/src/Symfony/Component/VarDumper/Tests/Dumper/HtmlDumperTest.php @@ -22,6 +22,10 @@ class HtmlDumperTest extends TestCase { public function testGet() { + if (ini_get('xdebug.file_link_format') || get_cfg_var('xdebug.file_link_format')) { + $this->markTestSkipped('A custom file_link_format is defined.'); + } + require __DIR__.'/../Fixtures/dumb-var.php'; $dumper = new HtmlDumper('php://output');