diff --git a/core/core.services.yml b/core/core.services.yml index e1afa8c..28eee86 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -692,7 +692,7 @@ services: - { name: event_subscriber } url_generator: class: Drupal\Core\Routing\UrlGenerator - arguments: ['@router.route_provider', '@path_processor_manager', '@route_processor_manager', '@config.factory', '@request_stack'] + arguments: ['@router.route_provider', '@path_processor_manager', '@route_processor_manager', '@request_stack', '%filter_protocols%'] calls: - [setContext, ['@?router.request_context']] redirect.destination: @@ -700,7 +700,7 @@ services: arguments: ['@request_stack', '@url_generator'] unrouted_url_assembler: class: Drupal\Core\Utility\UnroutedUrlAssembler - arguments: ['@request_stack', '@config.factory', '@path_processor_manager'] + arguments: ['@request_stack', '@config.factory', '@path_processor_manager', '%filter_protocols%] link_generator: class: Drupal\Core\Utility\LinkGenerator arguments: ['@url_generator', '@module_handler', '@renderer'] diff --git a/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php index bd3c1a0..9158dbe 100644 --- a/core/lib/Drupal/Core/Routing/UrlGenerator.php +++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php @@ -72,19 +72,18 @@ class UrlGenerator implements UrlGeneratorInterface { * The path processor to convert the system path to one suitable for urls. * @param \Drupal\Core\RouteProcessor\OutboundRouteProcessorInterface $route_processor * The route processor. - * @param \Drupal\Core\Config\ConfigFactoryInterface $config - * The config factory. * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack * A request stack object. + * @param string[] $filter_protocols + * An array of protocols allowed for url generation. */ - public function __construct(RouteProviderInterface $provider, OutboundPathProcessorInterface $path_processor, OutboundRouteProcessorInterface $route_processor, ConfigFactoryInterface $config, RequestStack $request_stack) { + public function __construct(RouteProviderInterface $provider, OutboundPathProcessorInterface $path_processor, OutboundRouteProcessorInterface $route_processor, RequestStack $request_stack, $filter_protocols = ['http', 'https']) { $this->provider = $provider; $this->context = new RequestContext(); $this->pathProcessor = $path_processor; $this->routeProcessor = $route_processor; - $allowed_protocols = $config->get('system.filter')->get('protocols') ?: array('http', 'https'); - UrlHelper::setAllowedProtocols($allowed_protocols); + UrlHelper::setAllowedProtocols($filter_protocols); $this->requestStack = $request_stack; } diff --git a/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php index 9556808..e257169 100644 --- a/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php +++ b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php @@ -40,14 +40,13 @@ class UnroutedUrlAssembler implements UnroutedUrlAssemblerInterface { * * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack * A request stack object. - * @param \Drupal\Core\Config\ConfigFactoryInterface $config - * The config factory. * @param \Drupal\Core\PathProcessor\OutboundPathProcessorInterface $path_processor * The output path processor. + * @param string[] $filter_protocols + * An array of protocols allowed for url generation. */ - public function __construct(RequestStack $request_stack, ConfigFactoryInterface $config, OutboundPathProcessorInterface $path_processor) { - $allowed_protocols = $config->get('system.filter')->get('protocols') ?: ['http', 'https']; - UrlHelper::setAllowedProtocols($allowed_protocols); + public function __construct(RequestStack $request_stack, OutboundPathProcessorInterface $path_processor, $filter_protocols = ['http', 'https']) { + UrlHelper::setAllowedProtocols($filter_protocols); $this->requestStack = $request_stack; $this->pathProcessor = $path_processor; } diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index 77b2794..cd23207 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -501,7 +501,7 @@ function _filter_url($text, $filter) { // we cannot cleanly differ between protocols here without hard-coding MAILTO, // so '//' is optional for all protocols. // @see \Drupal\Component\Utility\UrlHelper::filterBadProtocol() - $protocols = \Drupal::config('system.filter')->get('protocols'); + $protocols = \Drupal::getContainer()->getParameter('filter_protocols'); $protocols = implode(':(?://)?|', $protocols) . ':(?://)?'; $valid_url_path_characters = "[\p{L}\p{M}\p{N}!\*\';:=\+,\.\$\/%#\[\]\-_~@&]"; diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateSystemFilterTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateSystemFilterTest.php index c82bcc1..30d4ed7 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateSystemFilterTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateSystemFilterTest.php @@ -36,8 +36,8 @@ protected function setUp() { * Tests migration of system (filter) variables to system.filter.yml. */ public function testSystemFilter() { - $config = $this->config('system.filter'); - $this->assertIdentical(array('http', 'https', 'ftp', 'news', 'nntp', 'tel', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal', 'rtsp'), $config->get('protocols')); + $filter_parameters = \Drupal::getContainer()->getParameter('filter_protocols'); + $this->assertIdentical(array('http', 'https', 'ftp', 'news', 'nntp', 'tel', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal', 'rtsp'), $filter_parameters); } } diff --git a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php index 57edd51..8ff18e6 100644 --- a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php @@ -139,9 +139,7 @@ protected function setUp() { ->disableOriginalConstructor() ->getMock(); - $config_factory_stub = $this->getConfigFactoryStub(array('system.filter' => array('protocols' => array('http', 'https')))); - - $generator = new UrlGenerator($provider, $processor_manager, $this->routeProcessorManager, $config_factory_stub, $this->requestStack); + $generator = new UrlGenerator($provider, $processor_manager, $this->routeProcessorManager, $this->requestStack, ['http', 'https']); $generator->setContext($context); $this->generator = $generator; } diff --git a/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php b/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php index 98fab07..7b8404f 100644 --- a/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php +++ b/core/tests/Drupal/Tests/Core/Utility/UnroutedUrlAssemblerTest.php @@ -55,9 +55,8 @@ protected function setUp() { parent::setUp(); $this->requestStack = new RequestStack(); - $this->configFactory = $this->getConfigFactoryStub(['system.filter' => []]); $this->pathProcessor = $this->getMock('Drupal\Core\PathProcessor\OutboundPathProcessorInterface'); - $this->unroutedUrlAssembler = new UnroutedUrlAssembler($this->requestStack, $this->configFactory, $this->pathProcessor); + $this->unroutedUrlAssembler = new UnroutedUrlAssembler($this->requestStack, $this->pathProcessor); } /** diff --git a/sites/default/default.services.yml b/sites/default/default.services.yml index b5b6a17..c0c4f54 100755 --- a/sites/default/default.services.yml +++ b/sites/default/default.services.yml @@ -96,7 +96,7 @@ parameters: # Default key/value expirable storage service to use. # @default keyvalue.database.expirable # default: keyvalue.database.expirable - # Provider protoctols we allow to generate URLs for. + # Allowed protocols for URL generation. filter_protocols: - http - https