function RouterTest::testSuccessiveSlashes
Same name in other branches
- 10 core/modules/system/tests/src/Functional/Routing/RouterTest.php \Drupal\Tests\system\Functional\Routing\RouterTest::testSuccessiveSlashes()
- 11.x core/modules/system/tests/src/Functional/Routing/RouterTest.php \Drupal\Tests\system\Functional\Routing\RouterTest::testSuccessiveSlashes()
Ensure that multiple successive slashes are redirected.
File
-
core/
modules/ system/ tests/ src/ Functional/ Routing/ RouterTest.php, line 328
Class
- RouterTest
- Functional class for the full integrated routing system.
Namespace
Drupal\Tests\system\Functional\RoutingCode
public function testSuccessiveSlashes() {
$request = $this->container
->get('request_stack')
->getCurrentRequest();
// Test a simple path with successive leading slashes.
$url = $request->getUriForPath('//////router_test/test1');
$this->drupalGet($url);
$this->assertSession()
->addressEquals($request->getUriForPath('/router_test/test1'));
// Test successive slashes in the middle.
$url = $request->getUriForPath('/router_test//////test1') . '?qs=test';
$this->drupalGet($url);
$this->assertSession()
->addressEquals($request->getUriForPath('/router_test/test1') . '?qs=test');
// Ensure that external URLs in destination query params are not redirected
// to.
$url = $request->getUriForPath('/////////////////////////////////////////////////router_test/test1') . '?qs=test&destination=http://www.example.com%5c@drupal8alt.test';
$this->drupalGet($url);
$this->assertSession()
->addressEquals($request->getUriForPath('/router_test/test1') . '?qs=test');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.