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
1d6e7e25d5
commit
29689c24f3
|
@ -84,7 +84,7 @@ class PathWidget extends WidgetBase {
|
||||||
public static function validateFormElement(array &$element, FormStateInterface $form_state) {
|
public static function validateFormElement(array &$element, FormStateInterface $form_state) {
|
||||||
// Trim the submitted value of whitespace and slashes.
|
// Trim the submitted value of whitespace and slashes.
|
||||||
$alias = rtrim(trim($element['alias']['#value']), " \\/");
|
$alias = rtrim(trim($element['alias']['#value']), " \\/");
|
||||||
if (!empty($alias)) {
|
if ($alias !== '') {
|
||||||
$form_state->setValueForElement($element['alias'], $alias);
|
$form_state->setValueForElement($element['alias'], $alias);
|
||||||
|
|
||||||
/** @var \Drupal\path_alias\PathAliasInterface $path_alias */
|
/** @var \Drupal\path_alias\PathAliasInterface $path_alias */
|
||||||
|
|
|
@ -345,6 +345,12 @@ class PathAliasTest extends PathTestBase {
|
||||||
// Create sixth test node.
|
// Create sixth test node.
|
||||||
$node6 = $this->drupalCreateNode();
|
$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
|
// 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
|
// extra slash is removed when the link is generated. This ensures that URL
|
||||||
// aliases cannot be used to inject external URLs.
|
// aliases cannot be used to inject external URLs.
|
||||||
|
|
Loading…
Reference in New Issue