#35996 closed defect (bug) (fixed)
wp_normalize_path() not working with DFS on Windows hosting
Reported by: | rilwis | Owned by: | dd32 |
---|---|---|---|
Milestone: | 4.5 | Priority: | normal |
Severity: | normal | Version: | 3.9 |
Component: | Filesystem API | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
DFS on Windows hosting sets up the file path like this:
\\WDP\DFS\45\2\5\8\4513111852\user\sites\1627032.site\www
(Note the double forward slashes at the beginning).
After running wp_normalize_path(), the function returns
/WDP/DFS/45/2/5/8/4513111852/user/sites/1627032.site/www
which is a wrong path on DFS. If users use include or require function, then a warning or fatal error will be thrown:
require wp_normalize_path( __DIR__ ) . 'phpinfo.php';
The patch simply ignore double slashes at the beginning.
Attachments (2)
Change History (8)
#1
@
9 years ago
- Component changed from General to Filesystem API
- Keywords has-patch has-unit-tests added
- Milestone changed from Awaiting Review to 4.5
- Version changed from trunk to 3.9
#4
@
9 years ago
I'd just like to point out that the original code example in the ticket is invalid, you shouldn't do this, as it's completely unnecessary (and may also break):
require wp_normalize_path( __DIR__ ) . 'phpinfo.php';
wp_normalize_path()
is designed to be used to make two paths "sane" for comparison purposes, for example, to remove ABSPATH
from a filename and return the remainder - case differences in the path or extra slashes during path concatenation can cause the comparisons to fail otherwise.
35996.diff is wp_normalize_path-patch.diff with Docs and unit tests added.
I'm mildly concerned that linux paths with two leading slashes will be treated the same as the windows paths, however I don't think that edgecase is overly important - that'd only happen if the path was being concatenated incorrectly from the root.
Anyone else want to weigh in on that?
I see no reason this shouldn't be in 4.5.