Filter_var () accepts an invalid URL

Why filter_var() accept and verify this URL http://http://www.google.com ?

 $website = "http://http://www.google.com"; echo filter_var($website, FILTER_VALIDATE_URL); // This outputs the value of $website 

I think it's wrong. Any solution or bug fix for this?

phpinfo()

enter image description here

+6
source share
1 answer

Looks like you found a bug in PHP. The PHP manual states that FILTER_VALIDATE_URL checks uris according to http://www.faqs.org/rfcs/rfc2396.html

If you read the specification, PHP obviously will not be able to correctly verify its recommendations. In particular, in section 3 (Syntactic Components URIs), he determined that a scheme (http in your case) can exist only once and precedes a single colon in uri.

You must report this error at https://bugs.php.net/

Good work on this!

+2
source

Source: https://habr.com/ru/post/948180/


All Articles