Support scheme-relative URLs

Created on 14 February 2014, over 10 years ago
Updated 11 January 2021, over 3 years ago

Updated: Comment #N

Problem/Motivation

Currently the URL utility \Drupal\Component\Utility\Url just can validate (Url::isValid()) URL's with a defined scheme. However, an URL isn't required to explicitly define a scheme:
http://tools.ietf.org/html/rfc3986#section-4.2
http://url.spec.whatwg.org/#concept-scheme-relative-url

This functionality can become quite handy and we should support such URL structures.

Proposed resolution

Make sure the URL utility properly validates scheme relative URL's. To do so I suggest to adjust Url::isValid() to not explicitly check for schemes (https / ftp / feed) but instead check the pattern defined by RFC 3986 section 3.1 and allow scheme relative URLs at the same time.
Checking the scheme should be fully upon Url::stripDangerousProtocols() instead.

Remaining tasks

Reviews needed

User interface changes

None

API changes

None

✨ Feature request
Status

Needs work

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated 42 minutes ago

Created by

πŸ‡¨πŸ‡­Switzerland das-peter

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024