WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

Last modified 4 years ago

#29154 closed defect (bug) (fixed)

plugin_basename() doesn't normalize the file path before unresolving symlinks

Reported by: jdgrimes Owned by: ocean90
Milestone: 4.6 Priority: normal
Severity: normal Version: 3.9
Component: Plugins Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

In plugin_basename(), the $file is only passed through wp_normalize_path() after the attempt to unresolve symlinks. It should be normalized before this instead.

Introduced in: [27158]
Related: #16953, #28441

Attachments (4)

29154.diff (655 bytes) - added by jdgrimes 6 years ago.
29154.2.diff (637 bytes) - added by voldemortensen 6 years ago.
29154.3.patch (711 bytes) - added by flyingdr 5 years ago.
Created patch against current trunk (rev.37295)
29154.3.diff (1.6 KB) - added by ocean90 5 years ago.

Download all attachments as: .zip

Change History (13)

@jdgrimes
6 years ago

#1 @jdgrimes
6 years ago

  • Keywords has-patch added

#2 @voldemortensen
6 years ago

Refreshed for current trunk.

This ticket was mentioned in Slack in #core by jorbin. View the logs.


5 years ago

#4 @flyingdr
5 years ago

Any idea why this trivial patch waits for almost 2 years to be applied?

Latest available version 4.5 is still affected by this problem.

#5 @flyingdr
5 years ago

  • Keywords needs-testing added

I've tested 29154.2.diff on several sites that uses symlinks for plugins. It really solves problem with broken plugins in a case if they're installed using symlinks. Would be great to see this patch in 4.5.x or 4.6

@flyingdr
5 years ago

Created patch against current trunk (rev.37295)

@ocean90
5 years ago

#6 follow-up: @ocean90
5 years ago

  • Keywords has-unit-tests added; needs-testing removed
  • Milestone changed from Awaiting Review to 4.6

29154.3.diff includes a unit test which fails without the change to plugin_basename():

1) Tests_Plugin_Basename::test_should_return_correct_basename_for_symlinked_plugins
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-a-symlinked-plugin/plugin.php
+C:/www/path/plugins/a-plugin/plugin.php

#7 @ocean90
5 years ago

  • Owner set to ocean90
  • Resolution set to fixed
  • Status changed from new to closed

In 37332:

Plugins: In plugin_basename() normalize the file path before unresolving symlinks.

$wp_plugin_paths contains normalized paths, see wp_register_plugin_realpath().

Props jdgrimes, voldemortensen, flyingdr, ocean90.
Fixes #29154.

#8 @SergeyBiryukov
4 years ago

In 37719:

Plugins: Normalize WP_PLUGIN_DIR in the test added in [37332], otherwise it fails on Windows.

See #29154.

#9 in reply to: ↑ 6 @SergeyBiryukov
4 years ago

Replying to ocean90:

29154.3.diff includes a unit test which fails without the change to plugin_basename()

For reference, the test still failed on my install after [37332]:

1) Tests_Plugin_Basename::test_should_return_correct_basename_for_symlinked_plugins
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-a-symlinked-plugin/plugin.php
+S:\home\wordpress\develop/src/wp-content/plugins/a-symlinked-plugin/plugin.php

[37719] fixes that.

Note: See TracTickets for help on using tickets.