|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesHcPcEgmp (last revision 2021-10-31 04:13 UTC by sample at email dot tst)parse_url_windows_paths (last revision 2021-10-19 19:41 UTC by ppchelko at wikimedia dot org) Pull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2021-10-19 19:41 UTC] ppchelko at wikimedia dot org
[2021-10-20 08:23 UTC] cmb@php.net
[2021-10-20 14:37 UTC] ppchelko at wikimedia dot org
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 16:00:02 2025 UTC |
Description: ------------ parse_url looses the leading '/' character in paths with single-letter Windows drive letters. According to the RFC8089 Section 2[1]: > The generic syntax in [RFC3986] includes "path" and "authority" components, for each of which only a subset is used in the definition of the file URI scheme. The relevant subset of "path" is "path- absolute" 'path-absolute' in RFC3986 is defined as beginning with a '/' character. There's also a requirement in RFC3986 section 3.3 [2], that > If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character. For file:///c:/ URL the authority component is present but empty, which implies 'localhost'. Thus the 'path' component must begin with the '/' character. Other popular languages like Java or JavaScript preserve the leading slash character as well. [1] https://datatracker.ietf.org/doc/html/rfc8089#section-2 [2] https://datatracker.ietf.org/doc/html/rfc3986#section-3.3 Test script: --------------- var_dump( parse_url( 'file:///c:/' ) ); Expected result: ---------------- array(2) { ["scheme"]=> string(4) "file" ["path"]=> string(4) "/c:/" } Actual result: -------------- array(2) { ["scheme"]=> string(4) "file" ["path"]=> string(3) "c:/" }