only in patch2: unchanged: --- a/core/modules/link/tests/src/Functional/LinkFieldTest.php +++ b/core/modules/link/tests/src/Functional/LinkFieldTest.php @@ -148,10 +148,6 @@ public function testURLValidation() { 'route:' => '<nolink>', '' => '<none>', - // Query string and fragment. - '?example=llama' => '?example=llama', - '#example' => '#example', - // Entity reference autocomplete value. $node->label() . ' (1)' => $node->label() . ' (1)', // Entity URI displayed as ER autocomplete value when displayed in a form. @@ -177,6 +173,10 @@ public function testURLValidation() { 'entity:non_existing_entity_type/yar' => $validation_error_1, // URI for an entity that doesn't exist, with an invalid ID. 'entity:user/invalid-parameter' => $validation_error_1, + + // Query string and fragment. + '?example=llama' => '?example=llama', + '#example' => '#example', ]; // Test external and internal URLs for 'link_type' = LinkItemInterface::LINK_GENERIC. only in patch2: unchanged: --- a/core/modules/link/tests/src/Kernel/LinkItemUrlValidationTest.php +++ b/core/modules/link/tests/src/Kernel/LinkItemUrlValidationTest.php @@ -38,7 +38,9 @@ public function testExternalLinkValidation() { if (strpos($error_msg, '%')) { $error_msg = sprintf($error_msg, $value); } - $this->assertEquals($error_msg, $violations[$i++]->getMessage()); + $msg = $violations[$i++]->getMessage(); + $actual_msg = htmlspecialchars_decode(strip_tags($msg->render()), ENT_QUOTES); + $this->assertEquals($error_msg, $actual_msg); } } } @@ -54,6 +56,7 @@ public function testExternalLinkValidation() { protected function getTestLinks() { $violation_0 = "The path '%s' is invalid."; $violation_1 = 'This value should be of the correct primitive type.'; + $violation_2 = "The path/URL '\"%s\"' contains invalid characters."; return [ ['invalid://not-a-valid-protocol', [$violation_0]], ['http://www.example.com/', []], @@ -88,7 +91,7 @@ protected function getTestLinks() { ["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", []], + ["http://foo.com/unicode_(✪)_in_parens", [$violation_2]], ["http://foo.com/(something)?after=parens", []], ["http://☺.damowmow.com/", []], ["http://code.google.com/events/#&product=browser", []], @@ -97,10 +100,10 @@ protected function getTestLinks() { ["http://foo.bar/?q=Test%20URL-encoded%20stuff", []], ["http://مثال.إختبار", []], ["http://例子.测试", []], - ["http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com", []], + ["http://-.~_!$&'()*+,;=:%40:80%2f::::::@example.com", [$violation_2]], ["http://1337.net", []], ["http://a.b-c.de", []], - ["radar://1234", [$violation_0]], + ["rdar://1234", [$violation_0]], ["h://test", [$violation_0]], ["ftps://foo.bar/", [$violation_0]], // Use invalid URLS from