Opened 22 months ago
Last modified 22 months ago
#46561 new enhancement
Make wp_normalize_path() on Windows resolve drive letter for drive–relative paths
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | minor | Version: | |
Component: | Filesystem API | Keywords: | needs-patch |
Focuses: | Cc: |
Description
Though rarely used, Windows allows to omit drive letter in file path to treat is as drive–relative.
This causes inconsistency where paths pointing to the same dir are not normalized to the same representation by wp_normalize_path()
:
<?php var_dump( wp_normalize_path( 'C:\server\www\dev' ) ); // "C:/server/www/dev var_dump( wp_normalize_path( '\server\www\dev' ) ); // /server/www/dev << same path, but mismatch after normalize var_dump( wp_normalize_path( realpath( '\server\www\dev' ) ) ); // C:/server/www/dev << resolved drive letter before normalize
I think drive letter should be explicitly resolved as part of normalization for this case.
Change History (3)
Note: See
TracTickets for help on using
tickets.
One problem is that
wp_normalize_path()
doesn’t require path to be real, it normalizes path strings really. Introducingfile_exists()
check here feels somewhat unwanted.Maybe we should introduce a new function, something like
wp_normalize_real_path()
that will both validate path as valid filesystem path and normalize it?