|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1249 url_parse() is a bit too strict
Submitted: 1999-03-20 18:26 UTC Modified: 2004-08-05 16:39 UTC
From: kundrat at general-it dot sk Assigned:
Status: Closed Package: URL related
PHP Version: 4.0 OS: linux 2.2.1 glibc 2.0.7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: kundrat at general-it dot sk
New email:
PHP Version: OS:


 [1999-03-20 18:26 UTC] kundrat at general-it dot sk
it is a minor glitch, though parse_url('?') returns path
set, but query unset. After looking at url_parse() it seeems,
that is would be more rational to test for subs[7].rm_so <= lentgh
Equality case makes more sense for all the comparisons (maybe
except for scheme where it wouldnt matter). Result of this
would be, that any part that has its prefix present but value
absent and is at the end of string would be set (though empty)
Examples: '?' - query should be set, 'path#' fragment should
be set, 'http://' hostname should be set to empty
Another glitch is regexp for user:pass@host:port part. Now
the regexp is ^(([^@:]+)(:([^@:]+))?@)?([^:@]+)(:([^:@]+))?
while i suggest ^(([^@:]*)(:([^@:]*))?@)?([^:@]*)(:([^:@]*))?
This is also in accordance with regex for the whole url.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-10 13:12 UTC]
this is a real bug, although relatively minor.
 [2001-02-10 14:56 UTC]
refiled against 4.0.
 [2001-02-22 10:56 UTC]
I, personally, don't see why it has to parse such bogus URLs
at all... Any arguments?
 [2001-02-22 12:23 UTC] kundrat at general-it dot sk
If you get URL as user input it can be bogus. parse_url could
be very useful to find if the URL is bogus and what parts
of it are bogus. Another point is, that even bogus looking
URL's could be valid (partial only). Also i believe
that parse_url('path?') wouldnt have quere set (although i
cant verify it at the moment).
And the last point is correctness. Even if it is not
significant, it would be nice if it behaved the expected way.
 [2001-05-02 21:12 UTC]
To PHP-developers: Does anyone have any thoughts about this?
(IMO, this isn't any bug)


 [2001-05-07 07:57 UTC]
If this isn't a bug, it is at least an inconsistency.

parse_url('?') doesn't set a query key
parse_url('?#fragment') does

Neither URL has what I would consider a query string, but the query key is set in the second case.  That behavior should be consistent one way or the other, imho.
 [2001-05-07 12:54 UTC]
marking as fix before 4.0.6
 [2001-05-14 22:08 UTC]
Fixed in CVS. 

Now it behaves more consistently. 
ie. if ? is present, the query key is set.
And if # is present, the fragment key is set.


 [2004-08-05 16:41 UTC] derick at derickrethans dot nl
 [2004-09-26 21:43 UTC] ashley at klikgamers dot co dot uk
I do not even understand but it sounds like a bug to me...
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Jan 26 14:03:33 2022 UTC