Make WordPress Core

Opened 14 years ago

Closed 2 weeks ago

#18501 closed defect (bug) (invalid)

plugin_dir_path() returns unsanitized path on Windows installs

Reported by: johnjamesjacoby's profile johnjamesjacoby Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.8
Component: Plugins Keywords: needs-testing dev-feedback
Focuses: Cc:

Description

Currently plugin_dir_path() only returns the result of dirname( $file ), which can produce mixed results on local Windows installations.

Attached patch takes pieces from plugin_basename() and plugins_url() to guarantee a working and accurate plugin directory path is returned in all operating systems.

See #BB1596 (and associated revisions) for back-story.

Attachments (1)

18501.patch (1.4 KB) - added by johnjamesjacoby 14 years ago.

Download all attachments as: .zip

Change History (11)

#1 follow-up: @nacin
14 years ago

Doubt there's a need to fix plugin_dir_path() -- more likely, the issue is this code in search_theme_directories():

$theme_loc = str_replace(WP_CONTENT_DIR, '', $theme_root);

#2 @johnjamesjacoby
14 years ago

Probably right.

Possibly related: #4541

#3 @dd32
14 years ago

I believe this issue mainly arises from the fact that some constants on windows environments contain a mixture of \ and / in the paths (which stems from define( 'ABSPATH', dirname(__FILE__) . '/' ); using \), whilst most core functions standardise on / in created paths.. and even some of the API's do a str_replace('\\','/'..

ideally fixing this as low as possible would be better IMHO.

#4 @ramiy
14 years ago

#19200 - Related?

#5 @sorich87
14 years ago

  • Version set to 2.8

#6 in reply to: ↑ 1 @nacin
13 years ago

Replying to nacin:

$theme_loc = str_replace(WP_CONTENT_DIR, '', $theme_root);

This is actually dead code. $theme_loc is set up but never used. It will be removed in #20103.

#7 @pavelevap
13 years ago

  • Cc pavelevap@… added

#8 @Mamaduka
13 years ago

  • Cc georgemamadashvili@… added

#9 @chriscct7
10 years ago

  • Keywords dev-feedback added; has-patch removed

#10 @callumbw95
2 weeks ago

  • Resolution set to invalid
  • Status changed from new to closed

Hi All,
I have taken a look into this, and it looks like the issue with paths not working properly was resolved in 3.9 when the function wp_normalize_path() and has been expanded upon since (docs). Unfortunately, I don't have a Windows environment to test this. However, given that this ticket was opened a long time ago and we haven't received any other complaints on this topic, I'm confident that the issue has since been resolved. I'm going to close this ticket as invalid as it is no longer relevant in the latest release, however if you do have anything more to add to this conversation please reopen this ticket. 😃

Note: See TracTickets for help on using tickets.