Closed
Closed
Copy link
Description
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, '//')) {