php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77804 parse_url illegal host
Submitted: 2019-03-27 08:13 UTC Modified: 2019-06-14 12:03 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: 1085242202 at qq dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: master-Git-2019-03-27 (Git) OS: Red Hat Enterprise Linux Server
Private report: No CVE-ID: None
 [2019-03-27 08:13 UTC] 1085242202 at qq dot com
Description:
------------
"var_dump(parse_url('http://baidu.com\pinyin.sogou.com'));"
array(2) {
  ["scheme"]=>
  string(4) "http"
  ["host"]=>
  string(26) "baidu.com\pinyin.sogou.com"
}
"baidu.com\pinyin.sogou.com" maybe is an illegal host
ps:空格及符号如“?/\;:@#$%^~_=+,8. 。<>”等都不能用在域名命名 https://zhidao.baidu.com/question/337004301.html


Test script:
---------------
var_dump(parse_url('http://baidu.com\pinyin.sogou.com'));
array(2) {
  ["scheme"]=>
  string(4) "http"
  ["host"]=>
  string(26) "baidu.com\pinyin.sogou.com"
}

Expected result:
----------------
array(2) {
  ["scheme"]=>
  string(4) "http"
  ["host"]=>
  string(26) "baidu.com"
}

Actual result:
--------------
array(2) {
  ["scheme"]=>
  string(4) "http"
  ["host"]=>
  string(26) "baidu.com\pinyin.sogou.com"
}

Patches

patch.txt (last revision 2019-03-27 08:32 UTC by 1085242202 at qq dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-06-14 12:03 UTC] sjon@php.net
-Status: Open +Status: Not a bug
 [2019-06-14 12:03 UTC] sjon@php.net
I'm pretty sure the given domain-name is simply incorrect, as \ is not an allowed character according to https://tools.ietf.org/html/rfc1034

Additionally, the documentation of parse_url says:

> This function is not meant to validate the given URL, it only breaks it up into the above listed parts. 

so this is al pretty much expected behaviour
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Jun 16 13:01:28 2019 UTC