diff --git a/core/core.services.yml b/core/core.services.yml index 6e91dfe..8585a9a 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -7,7 +7,20 @@ parameters: default: keyvalue.database factory.keyvalue.expirable: default: keyvalue.expirable.database - filter_protocols: {} + filter_protocols: + - http + - https + - ftp + - news + - nntp + - tel + - telnet + - mailto + - irc + - ssh + - sftp + - webcal + - rtsp services: # Simple cache contexts, directly derived from the request context. cache_context.ip: diff --git a/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php index 9158dbe..b1d8f3e 100644 --- a/core/lib/Drupal/Core/Routing/UrlGenerator.php +++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php @@ -77,13 +77,13 @@ class UrlGenerator implements UrlGeneratorInterface { * @param string[] $filter_protocols * An array of protocols allowed for url generation. */ - public function __construct(RouteProviderInterface $provider, OutboundPathProcessorInterface $path_processor, OutboundRouteProcessorInterface $route_processor, RequestStack $request_stack, $filter_protocols = ['http', 'https']) { + public function __construct(RouteProviderInterface $provider, OutboundPathProcessorInterface $path_processor, OutboundRouteProcessorInterface $route_processor, RequestStack $request_stack, $filter_protocols) { $this->provider = $provider; $this->context = new RequestContext(); $this->pathProcessor = $path_processor; $this->routeProcessor = $route_processor; - UrlHelper::setAllowedProtocols($filter_protocols); + UrlHelper::setAllowedProtocols($filter_protocols ?: ['http', 'https']); $this->requestStack = $request_stack; } diff --git a/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php index e257169..788735a 100644 --- a/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php +++ b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php @@ -45,8 +45,8 @@ class UnroutedUrlAssembler implements UnroutedUrlAssemblerInterface { * @param string[] $filter_protocols * An array of protocols allowed for url generation. */ - public function __construct(RequestStack $request_stack, OutboundPathProcessorInterface $path_processor, $filter_protocols = ['http', 'https']) { - UrlHelper::setAllowedProtocols($filter_protocols); + public function __construct(RequestStack $request_stack, OutboundPathProcessorInterface $path_processor, $filter_protocols = []) { + UrlHelper::setAllowedProtocols($filter_protocols ?: ['http', 'https']); $this->requestStack = $request_stack; $this->pathProcessor = $path_processor; } diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index cd23207..468eb20 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::getContainer()->getParameter('filter_protocols'); + $protocols = \Drupal::getContainer()->getParameter('filter_protocols') ?: ['http', 'https']; $protocols = implode(':(?://)?|', $protocols) . ':(?://)?'; $valid_url_path_characters = "[\p{L}\p{M}\p{N}!\*\';:=\+,\.\$\/%#\[\]\-_~@&]"; diff --git a/core/modules/filter/src/Tests/FilterUnitTest.php b/core/modules/filter/src/Tests/FilterUnitTest.php index 8e6c5db..313643f 100644 --- a/core/modules/filter/src/Tests/FilterUnitTest.php +++ b/core/modules/filter/src/Tests/FilterUnitTest.php @@ -593,7 +593,7 @@ function testUrlFilter() { ), // Absolute URL protocols. // The list to test is found in the beginning of _filter_url() at - // $protocols = $this->config('system.filter')->get('protocols'). + // $protocols = \Drupal::getContainer()->getParameter('filter_protocols'). ' https://example.com, ftp://ftp.example.com, diff --git a/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php index 11b6eb8..4134662 100644 --- a/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php @@ -168,16 +168,8 @@ protected function setUp() { * Sets up the unrouted url assembler and the link generator. */ protected function setUpUrlIntegrationServices() { - $config = $this->getMockBuilder('Drupal\Core\Config\ImmutableConfig') - ->disableOriginalConstructor() - ->getMock(); - $config_factory = $this->getMock('\Drupal\Core\Config\ConfigFactoryInterface'); - $config_factory->expects($this->any()) - ->method('get') - ->willReturn($config); - $this->pathProcessor = $this->getMock('Drupal\Core\PathProcessor\OutboundPathProcessorInterface'); - $this->unroutedUrlAssembler = new UnroutedUrlAssembler($this->requestStack, $config_factory, $this->pathProcessor); + $this->unroutedUrlAssembler = new UnroutedUrlAssembler($this->requestStack, $this->pathProcessor); \Drupal::getContainer()->set('unrouted_url_assembler', $this->unroutedUrlAssembler);