From 068bb1a01866e6d58d1f7e4dc791310c2330bb76 Mon Sep 17 00:00:00 2001 From: webchick <drupal@webchick.net> Date: Mon, 13 Oct 2014 21:19:25 -0700 Subject: [PATCH] Issue #2353347 follow-up by dawehner, alexpott: Fixed Random failure in DisplayPathTest. --- .../views/src/Plugin/views/display/PathPluginBase.php | 5 +++++ core/modules/views_ui/src/Tests/DisplayPathTest.php | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core/modules/views/src/Plugin/views/display/PathPluginBase.php b/core/modules/views/src/Plugin/views/display/PathPluginBase.php index 754408c1faa4..2d7e550f8fe6 100644 --- a/core/modules/views/src/Plugin/views/display/PathPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/PathPluginBase.php @@ -15,6 +15,7 @@ use Drupal\Core\State\StateInterface; use Drupal\Core\Routing\RouteCompiler; use Drupal\Core\Routing\RouteProviderInterface; +use Drupal\Core\Url; use Drupal\views\Views; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -460,6 +461,10 @@ protected function validatePath($path) { $errors[] = $this->t('No query allowed.'); } + if (!parse_url('base://' . $path)) { + $errors[] = $this->t('Invalid path. Valid characters are alphanumerics as well as "-", ".", "_" and "~".'); + } + $path_sections = explode('/', $path); // Symfony routing does not allow to use numeric placeholders. // @see \Symfony\Component\Routing\RouteCompiler diff --git a/core/modules/views_ui/src/Tests/DisplayPathTest.php b/core/modules/views_ui/src/Tests/DisplayPathTest.php index f174e6a640e7..b8c04402782d 100644 --- a/core/modules/views_ui/src/Tests/DisplayPathTest.php +++ b/core/modules/views_ui/src/Tests/DisplayPathTest.php @@ -105,8 +105,12 @@ public function testMenuOptions() { $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', array('path' => '?bar'), t('Apply')); $this->assertText('Path is empty'); + // Add an invalid path from a random test failure. + $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', array('path' => 'AKI@&hO@'), t('Apply')); + $this->assertText('Invalid path'); + // Provide a random, valid path string. - $random_string = str_replace(['?', '#'], '_', $this->randomString()); + $random_string = $this->randomMachineName(); // Save a path. $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', array('path' => $random_string), t('Apply')); -- GitLab