Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#35996 closed defect (bug) (fixed)

wp_normalize_path() not working with DFS on Windows hosting

Reported by: rilwis's profile rilwis Owned by: dd32's profile 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)

wp_normalize_path-patch.diff (477 bytes) - added by rilwis 8 years ago.
35996.diff (3.1 KB) - added by dd32 8 years ago.

Download all attachments as: .zip

Change History (8)

@dd32
8 years ago

#1 @dd32
8 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

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.

#2 @kirasong
8 years ago

  • Owner set to dd32
  • Status changed from new to assigned

#3 @dd32
8 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 36881:

Filesystem: Support Windows shares/DFS roots in wp_normalize_path().

Props rilwis for initial patch.
Fixes #35996.

#4 @dd32
8 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.

#5 @dd32
8 years ago

In 36882:

Tests: Merge the two different wp_normalize_path() tests.

See #35996, [36881].

#6 @johnbillion
5 years ago

In 45012:

Build/Test tools: Backport the fixed tests for wp_normalize_path() from the 4.5 branch into 4.4.

See #35996

Note: See TracTickets for help on using tickets.