Issue #3232681 by Matroskeen, danflanagan8, kpaxman, quietone: FieldLink process plugin treats protocol-relative external URLs as internal ones
parent
4bc7dbb8f9
commit
e57ef27b2d
|
@ -59,6 +59,13 @@ class FieldLink extends ProcessPluginBase {
|
|||
* @see \Drupal\link\Plugin\Field\FieldWidget\LinkWidget::getUserEnteredStringAsUri()
|
||||
*/
|
||||
protected function canonicalizeUri($uri) {
|
||||
// If the path starts with 2 slashes then it is always considered an
|
||||
// external URL without an explicit protocol part.
|
||||
// @todo Remove this when https://www.drupal.org/node/2744729 lands.
|
||||
if (strpos($uri, '//') === 0) {
|
||||
return $this->configuration['uri_scheme'] . ltrim($uri, '/');
|
||||
}
|
||||
|
||||
// If we already have a scheme, we're fine.
|
||||
if (parse_url($uri, PHP_URL_SCHEME)) {
|
||||
return $uri;
|
||||
|
|
|
@ -66,6 +66,10 @@ class FieldLinkTest extends UnitTestCase {
|
|||
'https://yahoo.com',
|
||||
['uri_scheme' => 'https://'],
|
||||
],
|
||||
'Absolute URL without explicit protocol (protocol-relative)' => [
|
||||
'//example.com',
|
||||
'http://example.com',
|
||||
],
|
||||
'Absolute URL with non-standard characters' => [
|
||||
'http://www.ßÀÑÐ¥ƒå¢ë.com',
|
||||
'http://www.ßÀÑÐ¥ƒå¢ë.com',
|
||||
|
|
Loading…
Reference in New Issue