Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 8 years ago

#35996 closed defect (bug) (fixed)

wp_normalize_path() not working with DFS on Windows hosting

Reported by: rilwis Owned by: dd32
Priority: normal Milestone: 4.5
Component: Filesystem API Version: 3.9
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses:

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 11 years ago.
35996.diff​ (3.1 KB ) - added by dd32 11 years ago.

Download all attachments as: .zip

Change History (8)

@dd32
11 years ago

#1 @dd32
11 years ago

  • Component General → Filesystem API
  • Keywords has-patch has-unit-tests added
  • Milestone Awaiting Review → 4.5
  • Version trunk → 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
11 years ago

  • Owner set to dd32
  • Status new → assigned

#3 @dd32
11 years ago

  • Resolution → fixed
  • Status assigned → closed

In 36881:

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

Props rilwis for initial patch.
Fixes #35996.

#4 @dd32
11 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
11 years ago

In 36882:

Tests: Merge the two different wp_normalize_path() tests.

See #35996, [36881].

#6 @johnbillion
8 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.