Commit 15a3f2de authored by webchick's avatar webchick

Issue #2501655 by tim.plunkett, hchonov, willzyx:...

Issue #2501655 by tim.plunkett, hchonov, willzyx: ConfirmFormHelper::buildCancelLink() incorrectly handles ?destination URLs with a leading slash
parent 0afbdd4c
......@@ -34,7 +34,7 @@ public static function buildCancelLink(ConfirmFormInterface $form, Request $requ
if ($query->has('destination')) {
$options = UrlHelper::parse($query->get('destination'));
// @todo Revisit this in https://www.drupal.org/node/2418219.
$url = Url::fromUserInput('/' . $options['path'], $options);
$url = Url::fromUserInput('/' . ltrim($options['path'], '/'), $options);
}
// Check for a route-based cancel link.
else {
......
......@@ -92,9 +92,11 @@ public function testCancelLinkRouteWithUrl() {
* @covers ::buildCancelLink
*
* Tests a cancel link provided by the destination.
*
* @dataProvider providerTestCancelLinkDestination
*/
public function testCancelLinkDestination() {
$query = array('destination' => 'baz');
public function testCancelLinkDestination($destination) {
$query = array('destination' => $destination);
$form = $this->getMock('Drupal\Core\Form\ConfirmFormInterface');
$path_validator = $this->getMock('Drupal\Core\Path\PathValidatorInterface');
......@@ -112,4 +114,14 @@ public function testCancelLinkDestination() {
$this->assertSame($url, $link['#url']);
}
/**
* Provides test data for testCancelLinkDestination().
*/
public function providerTestCancelLinkDestination() {
$data = [];
$data[] = ['baz'];
$data[] = ['/baz'];
return $data;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment