Unverified Commit 63b8c894 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

(cherry picked from commit e57ef27b)
parent 88bb7758
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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;
+4 −0
Original line number Diff line number Diff line
@@ -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',