Commit 29689c24 authored by catch's avatar catch

Issue #268909 by maartenvg, raman.b, paulocs, lyricnz, Abhijith S, webchick,...

Issue #268909 by maartenvg, raman.b, paulocs, lyricnz, Abhijith S, webchick, Freso, chx, pameeela: "0" can't be used a path alias, but no error is shown
parent 1d6e7e25
......@@ -84,7 +84,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
public static function validateFormElement(array &$element, FormStateInterface $form_state) {
// Trim the submitted value of whitespace and slashes.
$alias = rtrim(trim($element['alias']['#value']), " \\/");
if (!empty($alias)) {
if ($alias !== '') {
$form_state->setValueForElement($element['alias'], $alias);
/** @var \Drupal\path_alias\PathAliasInterface $path_alias */
......
......@@ -345,6 +345,12 @@ public function testNodeAlias() {
// Create sixth test node.
$node6 = $this->drupalCreateNode();
// Test the special case where the alias is '0'.
$edit = ['path[0][alias]' => '0'];
$this->drupalGet($node6->toUrl('edit-form'));
$this->submitForm($edit, 'Save');
$this->assertSession()->pageTextContains('The alias path has to start with a slash.');
// Create an invalid alias with two leading slashes and verify that the
// extra slash is removed when the link is generated. This ensures that URL
// aliases cannot be used to inject external URLs.
......
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