Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Form] Skipped URL protocol "//~" is normal but not valid by FixUrlProtocolListener #42329

Copy link
Copy link
Closed
@alexanevsky

Description

@alexanevsky
Issue body actions

Symfony version(s) affected: <=5.3

Description

It is normal to use links without absolute protocol, just: //symfony.com

After following a link without a protocol (only with double slashes), browsers will automatically detect the protocol. So it is correct to use these links. Try and see: //symfony.com

But Symfony Form UrlType adds a default protocol to these URLs (//symfony.com => http:////symfony.com).

How to reproduce
Paste //symfony.com to Form UrlType, submit the form and see what happens.

Possible Solution
In Symfony\Component\Form\Extension\Core\EventListener\FixUrlProtocolListener
Find:

if ($this->defaultProtocol && $data && \is_string($data) && !preg_match('~^[\w+.-]+://~', $data)) {

Replace to:

if ($this->defaultProtocol && $data && \is_string($data) && !preg_match('~^[\w+.-]+://~', $data) && 0 !== strpos($data, '//')) {

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.