WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 22 months ago

#18501 new defect (bug)

plugin_dir_path() returns unsanitized path on Windows installs

Reported by: johnjamesjacoby Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 2.8
Component: Plugins Keywords: needs-testing has-patch
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 3 years ago.

Download all attachments as: .zip

Change History (9)

johnjamesjacoby3 years ago

comment:1 follow-up: nacin3 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);

comment:2 johnjamesjacoby3 years ago

Probably right.

Possibly related: #4541

comment:3 dd323 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.

comment:4 ramiy2 years ago

#19200 - Related?

comment:5 sorich872 years ago

  • Version set to 2.8

comment:6 in reply to: ↑ 1 nacin2 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.

comment:7 pavelevap2 years ago

  • Cc pavelevap@… added

comment:8 Mamaduka22 months ago

  • Cc georgemamadashvili@… added
Note: See TracTickets for help on using tickets.