php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #53901 parse_url() discards invalid port number
Submitted: 2011-02-01 13:28 UTC Modified: 2011-02-04 12:19 UTC
From: aaz at althenia dot net Assigned: aharvey (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.5 OS:
Private report: No CVE-ID: None
 [2011-02-01 13:28 UTC] aaz at althenia dot net
Description:
------------
parse_url("http://example.com:qq");

Array
(
    [scheme] => http
    [host] => example.com
)

The port number "qq" is not included, so based on this output there is no way
to determine in later code that the URL was invalid.

Relatedly, the port number is returned as an int, while the manual says that
every component is returned as a string.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-01 14:18 UTC] cataphract@php.net
-Type: Bug +Type: Documentation Problem
 [2011-02-01 14:18 UTC] cataphract@php.net
Partially bogus, as the documentation says, "parse_url" is not meant to validate URLs. Use the filter extension for that.

The second part about it returning an int is true though.
 [2011-02-01 15:32 UTC] aaz at althenia dot net
I didn't expect parse_url() to validate the URL, but I did want it to
give me all the pieces that it found so I could validate or compare
them with other URLs myself.

Since internally php_url has an integer field for the port, I guess
it's too difficult to make it return the original port string.

Regarding the filter extension, the above URL passes validation (see
bug #49197).
 [2011-02-04 12:11 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&revision=308017
Log: Fix doc bug #53901 (parse_url() discards invalid port number).
 [2011-02-04 12:19 UTC] aharvey@php.net
-Status: Open +Status: Closed -Package: URL related +Package: Documentation problem -Assigned To: +Assigned To: aharvey
 [2011-02-04 12:19 UTC] aharvey@php.net
Documentation fix committed. I've opened bug #53924 for the filter issue.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC