Skip to content

symfony/validator UrlValidator passes invalid urls #39986

Closed
@p4veI

Description

@p4veI

Symfony version(s) affected: 5.x.x (probably even previous versions)

Description
https://github.com/symfony/Validator/blob/master/Constraints/UrlValidator.php
symfony/validator's UrlValidator class pattern passes/validates an invalid url without a top level domain name extension, e.g. .com and doesn't throw exception

How to reproduce

$url = 'http://invalidurl'
$validator = new UrlValidator();
$validator->validate($url, new Url());

Additional context
I've come across this issue while using beberlei/assert which uses the pattern for url assertion, there's a direct link to the UrlValidator here on github from symfony, I've tried to check the pattern in both libraries and both seem to validate the invalid url as valid. See here - I consider the first example invalid, hope I'm not wrong.

Thanks for looking into this.

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