You are here

public function UrlHelperTest::testStripDangerousProtocols in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::testStripDangerousProtocols()
  2. 9 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

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 492

Class

UrlHelperTest
@group Utility

Namespace

Drupal\Tests\Component\Utility

Code

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