|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53924 FILTER_VALIDATE_URL doesn't validate port numbers
Submitted: 2011-02-04 12:18 UTC Modified: 2011-02-04 22:41 UTC
From: Assigned: iliaa (profile)
Status: Closed Package: Filter related
PHP Version: trunk-SVN-2011-02-04 (SVN) OS: Irrelevant
Private report: No CVE-ID: None
 [2011-02-04 12:18 UTC]
Non-integer port numbers are currently validated as OK by FILTER_VALIDATE_URL, 
per a comment in bug #53901.

Test script:
var_dump(filter_var('', FILTER_VALIDATE_URL));

Expected result:

Actual result:
string(21) ""


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-04 15:34 UTC] aaz at althenia dot net

Since this filter uses parse_url() internally, I suggest the easiest
fix would be to make parse_url() return FALSE here.

Note that parse_url() already does some validation of the port number:

   parse_url('');  // OK
   parse_url(''); // FALSE
 [2011-02-04 22:41 UTC]
Automatic comment from SVN on behalf of iliaa
Log: Fixed bug #53924 (FILTER_VALIDATE_URL doesn't validate port number).
 [2011-02-04 22:41 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: iliaa
 [2011-02-04 22:41 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Dec 05 13:01:26 2023 UTC