diff -u b/core/modules/link/tests/src/Functional/LinkFieldTest.php b/core/modules/link/tests/src/Functional/LinkFieldTest.php --- b/core/modules/link/tests/src/Functional/LinkFieldTest.php +++ b/core/modules/link/tests/src/Functional/LinkFieldTest.php @@ -163,9 +163,9 @@ $validation_error_2 = 'Manually entered paths should start with one of the following characters: / ? #'; $validation_error_3 = "The path '@link_path' is inaccessible."; $invalid_external_entries = [ - // Invalid protocol + // Invalid protocol. 'invalid://not-a-valid-protocol' => $validation_error_1, - // Missing host name + // Missing host name. 'http://' => $validation_error_1, ]; $invalid_internal_entries = [ @@ -220,7 +220,7 @@ $this->drupalGet('entity_test/add'); $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); - $id = $match[1]; + $id = !empty($match) ? $match[1] : ''; $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); $this->assertRaw('"' . $string . '"'); } @@ -416,7 +416,8 @@ $this->drupalGet('entity_test/add'); $url1 = 'http://www.example.com/content/articles/archive?author=John&year=2012#com'; $url2 = 'http://www.example.org/content/articles/archive?author=John&year=2012#org'; - $url3 = '#net'; + // The (#tag) fragment is tested within testURLValidation(). + $url3 = '/#tag'; $title1 = $url1; // Intentionally contains an ampersand that needs sanitization on output. $title2 = 'A very long & strange example title that could break the nice layout of the site'; @@ -434,7 +435,7 @@ $this->assertSession()->pageTextContains('Read more about this entity'); $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); - $id = $match[1]; + $id = !empty($match) ? $match[1] : ''; $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); // Verify that the link is output according to the formatter settings. @@ -453,6 +454,7 @@ ['url_only' => TRUE, 'url_plain' => TRUE], ], ]; + $url3 = Url::fromUserInput($url3, [])->toString(); foreach ($options as $setting => $values) { foreach ($values as $new_value) { // Update the field formatter settings. @@ -572,7 +574,7 @@ $this->drupalGet('entity_test/add'); $url1 = 'http://www.example.com/content/articles/archive?author=John&year=2012#com'; $url2 = 'http://www.example.org/content/articles/archive?author=John&year=2012#org'; - $url3 = '#net'; + $url3 = '/#net'; // Intentionally contains an ampersand that needs sanitization on output. $title2 = 'A very long & strange example title that could break the nice layout of the site'; $title3 = 'Fragment only'; @@ -585,7 +587,7 @@ ]; $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); - $id = $match[1]; + $id = !empty($match) ? $match[1] : ''; $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.'); // Verify that the link is output according to the formatter settings. @@ -594,6 +596,7 @@ 'rel' => [NULL, 'nofollow'], 'target' => [NULL, '_blank'], ]; + $url3 = Url::fromUserInput($url3, [])->toString(); foreach ($options as $setting => $values) { foreach ($values as $new_value) { // Update the field formatter settings. @@ -803,7 +806,7 @@ $this->drupalGet('/entity_test/add'); $this->submitForm($edit, 'Save'); preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match); - $id = $match[1]; + $id = !empty($match) ? $match[1] : ''; $output = $this->renderTestEntity($id); $expected_link = (string) $this->container->get('link_generator')->generate('Title, no link', Url::fromUri('route:')); $this->assertStringContainsString($expected_link, $output); diff -u b/core/modules/link/tests/src/Kernel/LinkItemUrlValidationTest.php b/core/modules/link/tests/src/Kernel/LinkItemUrlValidationTest.php --- b/core/modules/link/tests/src/Kernel/LinkItemUrlValidationTest.php +++ b/core/modules/link/tests/src/Kernel/LinkItemUrlValidationTest.php @@ -91,7 +91,7 @@ ["http://foo.com/blah_(wikipedia)#cite-1", []], ["http://foo.com/blah_(wikipedia)_blah#cite-1", []], // The following invalid URLs produce false positives. - ["http://foo.com/unicode_(✪)_in_parens", [$violation_2]], + ["http://foo.com/unicode_(✪)_in_parens", [$violation_2]], ["http://foo.com/(something)?after=parens", []], ["http://☺.damowmow.com/", []], ["http://code.google.com/events/#&product=browser", []], @@ -103,7 +103,7 @@ ["http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com", [$violation_2]], ["http://1337.net", []], ["http://a.b-c.de", []], - ["rdar://1234", [$violation_0]], + ["radar://1234", [$violation_0]], ["h://test", [$violation_0]], ["ftps://foo.bar/", [$violation_0]], // Use invalid URLS from