function UrlHelperTest::testStripDangerousProtocols

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::testStripDangerousProtocols()
  2. 8.9.x core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::testStripDangerousProtocols()
  3. 10 core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::testStripDangerousProtocols()

Tests dangerous URL protocol filtering.

@dataProvider providerTestStripDangerousProtocols @covers ::setAllowedProtocols @covers ::stripDangerousProtocols

@runInSeparateProcess

Parameters

string $uri: Protocol URI.

string $expected: Expected escaped value.

array $protocols: Protocols to allow.

File

core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php, line 524

Class

UrlHelperTest
@group Utility

Namespace

Drupal\Tests\Component\Utility

Code

public function testStripDangerousProtocols($uri, $expected, $protocols) : void {
    UrlHelper::setAllowedProtocols($protocols);
    $stripped = UrlHelper::stripDangerousProtocols($uri);
    $this->assertEquals($expected, $stripped);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.