Skip to content
Snippets Groups Projects
Unverified Commit e57ef27b authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3232681 by Matroskeen, danflanagan8, kpaxman, quietone: FieldLink...

Issue #3232681 by Matroskeen, danflanagan8, kpaxman, quietone: FieldLink process plugin treats protocol-relative external URLs as internal ones
parent 4bc7dbb8
No related branches found
No related tags found
No related merge requests found
......@@ -59,6 +59,13 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
* @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 @@ public function canonicalizeUriDataProvider() {
'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',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment