rfc:replace_parse_url
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:replace_parse_url [2016/10/03 22:56] – bp1222 | rfc:replace_parse_url [2021/03/27 14:57] (current) – Move to inactive ilutov | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== PHP RFC: Replace parse_url() | + | ====== PHP RFC: Create RFC Compliant URL Parser |
- | * Version: 0.1 | + | * Version: 0.3 |
- | * Date: 2016-10-03 | + | * Date: 2016-10-04 |
* Author: David Walker (dave@mudsite.com) | * Author: David Walker (dave@mudsite.com) | ||
- | * Status: | + | |
+ | | ||
* First Published at: http:// | * First Published at: http:// | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | This RFC came about for an attempt to resolve [[https:// | + | This RFC came about for an attempt to resolve [[https:// |
- | <file php> | + | The current implementation of '' |
- | <?php | + | |
- | var_dump(parse_url("127.0.0.1:80", | + | |
- | /* Outputs: | + | So, this RFC proposes creating a new parser that adheres to the two RFC's. In doing so, if PHP is compiled with mbstring support, would be able to properly support multibyte characters in a URL. |
- | string(9) "127.0.0.1" | + | |
- | */ | + | |
- | </ | + | |
- | While we all may agree that this is sensible, and totally expected, it is actually a lie. That is not how the RFC defines how that string should be interpreted. | + | ===== Proposal ===== |
- | + | ||
- | So a RFC standard implementation should be parsed as such: | + | |
<file php> | <file php> | ||
<?php | <?php | ||
- | var_dump(parse_url(" | ||
- | var_dump(parse_url(" | ||
- | /* Outputs: | + | class URL { |
- | NULL | + | public function |
- | string(12) " | + | |
- | */ | + | |
- | </ | + | * $input - The string |
- | + | * $base - (optional) If $url is relative, this is what it is relative to | |
- | The bug does state that the parsing difference between IPv4 address and IPv6 addresses are handled differently | + | |
- | + | * $url - (optional) A URL object | |
- | <file php> | + | * $state_override - (optional) begin parting |
- | <?php | + | */ |
- | var_dump(parse_url(" | + | |
- | var_dump(parse_url("[::1]: | + | |
+ | public function getScheme() : ?string; | ||
+ | | ||
+ | public function getPassword() : ?string; | ||
+ | public function getHostname() : ?string; | ||
+ | public function getPort() : ?int; | ||
+ | | ||
+ | public function getQuery() : ?string; | ||
+ | public function getFragment() | ||
+ | |||
+ | public function getAll() : array; | ||
+ | } | ||
- | /* Outputs: | ||
- | string(12) " | ||
- | NULL | ||
- | */ | ||
</ | </ | ||
- | |||
- | This is due to the rules of the path, which allow a path to begin with a ''/'', | ||
- | |||
- | <file php> | ||
- | <?php | ||
- | var_dump(parse_url(" | ||
- | var_dump(parse_url(" | ||
- | |||
- | var_dump(parse_url("// | ||
- | var_dump(parse_url("// | ||
- | |||
- | /* Outputs: | ||
- | string(22) " | ||
- | NULL | ||
- | string(10) "/ | ||
- | string(10) "/ | ||
- | |||
- | */ | ||
- | </ | ||
- | |||
- | ===== Proposal ===== | ||
- | The proposal of this RFC is two fold. One, replace the current parser used for '' | ||
- | |||
- | The function can return | ||
- | * An array consisting of each component of the URI found. | ||
- | * A string|int of the component requested by the 2nd argument | ||
- | * NULL when we can not parse the URI, or, the component request contains no value | ||
- | |||
- | ===== Discussion Points ===== | ||
- | ==== RFC Break ==== | ||
- | I do make a single exception and break with the RFC in one place. | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | Many of the tests that were developed for the current implementation of '' | + | None |
- | + | ||
- | ===== Proposed PHP Version(s) ===== | + | |
- | PHP 7.2, or later | + | |
===== RFC Impact ===== | ===== RFC Impact ===== | ||
==== To Existing Extensions ==== | ==== To Existing Extensions ==== | ||
- | standard | + | standard |
===== Open Issues ===== | ===== Open Issues ===== | ||
- | Make sure there are no open issues when the vote starts! | + | * Deprecate '' |
- | + | * Should '' | |
- | ===== Unaffected PHP Functionality ===== | + | |
- | List existing areas/ | + | |
- | + | ||
- | This helps avoid any ambiguity, shows that you have thought deeply about the RFC's impact, and helps reduces mail list noise. | + | |
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
- | Vote to replace '' | ||
Requires 2/3 | Requires 2/3 | ||
Line 105: | Line 65: | ||
===== References ===== | ===== References ===== | ||
- | PR with working Implementation: |
rfc/replace_parse_url.txt · Last modified: 2021/03/27 14:57 by ilutov