|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-06-27 03:39 UTC] demtheman at yahoo dot com
Description: ------------ I used filter_var() to validate the URL http://http://www.google.com (as test URL), however it seems to see it as valid which in fact is wrong. Refer to my SO question http://stackoverflow.com/questions/17333612/filter-var-accepts-invalid- url Test script: --------------- $website = "http://http://www.google.com"; echo filter_var($website, FILTER_VALIDATE_URL); Expected result: ---------------- The filter_var() should return FALSE. Actual result: -------------- The filter_var() returns the filtered data. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 21:00:01 2025 UTC |
According to RFC 2396 Appendix A the example URI doesn't seem to be valid, even if it passes the regular expression given in Appendix B. However, filter_var($var, FILTER_VALIDATE_URL) is based on parse_url(). parse_url('http://http://example.com') evaluates to: Array ( [scheme] => http [host] => http [path] => //example.com ) This is apparently wrong in this case according to RFC 2396; neither an abs_path nor a rel_path must start with a double slash.