php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71960 parse_url() return empty query, empty fragment
Submitted: 2016-04-04 20:51 UTC Modified: 2016-04-24 04:22 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: whatchildisthis at gmail dot com Assigned: jhdxr (profile)
Status: No Feedback Package: URL related
PHP Version: 7.0.5 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-04-04 20:51 UTC] whatchildisthis at gmail dot com
Description:
------------
parse_url() returns an index for a 0-length username and 0-length password, but not for a 0-length query or fragment. (http://www.faqs.org/rfcs/rfc3986.html)

Test script:
---------------
<?php
print_r(parse_url("http://example.com");
print_r(parse_url("http://:@example.com?#");
?>

Expected result:
----------------
array (
  'scheme' => 'http',
  'host' => 'example.com',
)array (
  'scheme' => 'http',
  'host' => 'example.com',
  'user' => '',
  'pass' => '',
  'query' => '',
  'fragment' => '',
)

Actual result:
--------------
array (
  'scheme' => 'http',
  'host' => 'example.com',
)array (
  'scheme' => 'http',
  'host' => 'example.com',
  'user' => '',
  'pass' => '',
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-04 20:54 UTC] whatchildisthis at gmail dot com
(Edit: Corrected var_export() in test script, not print_r())

Description:
------------
parse_url() returns an index for a 0-length username and 0-length password, but not for a 0-length query or fragment. (http://www.faqs.org/rfcs/rfc3986.html)

Test script:
---------------
<?php
var_export(parse_url("http://example.com");
var_export(parse_url("http://:@example.com?#");
?>

Expected result:
----------------
array (
  'scheme' => 'http',
  'host' => 'example.com',
)array (
  'scheme' => 'http',
  'host' => 'example.com',
  'user' => '',
  'pass' => '',
  'query' => '',
  'fragment' => '',
)

Actual result:
--------------
array (
  'scheme' => 'http',
  'host' => 'example.com',
)array (
  'scheme' => 'http',
  'host' => 'example.com',
  'user' => '',
  'pass' => '',
)
 [2016-04-15 08:56 UTC] jhdxr@php.net
-Assigned To: +Assigned To: jhdxr
 [2016-04-15 14:22 UTC] jhdxr@php.net
-Status: Assigned +Status: Feedback
 [2016-04-15 14:22 UTC] jhdxr@php.net
There are some test cases in parse_url_basic_007.phpt proving that the following cases are worked as expected:
1. http://www.php.net/? ==> no query
2. http://www.php.net:80/?#  ==> no query and no fragment

and there is nothing indicating query string or frament can be empty(0-length), while the section of authority says it can be empty clearly.


So could you give more info to prove that we should phrase empty query or empty fragment?
 [2016-04-24 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 23:01:34 2024 UTC