Opened 8 months ago
Closed 8 months ago
#22138 closed defect (bug) (fixed)
wp_basename wrong on Windows Systems
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.5 |
| Component: | Formatting | Version: | 3.4.2 |
| Severity: | normal | Keywords: | has-patch commit |
| Cc: | knut@…, bpetty |
Description
On Windows System the Directory Seperator is \ instead of Unix /.
So the urlencode in wp_basename() encodes the \ and it is not removed in basename().
WP_basename is not working properly on Windows Systems.
Just take a look in the Support Forum:
http://wordpress.org/support/topic/function-wp_basename-is-wrong-in-windows?replies=3
Attachments (1)
Change History (11)
SergeyBiryukov
— 8 months ago
comment:2
SergeyBiryukov
— 8 months ago
- Keywords has-patch needs-unit-tests added; needs-patch removed
- Milestone changed from Awaiting Review to 3.5
Confirmed. wp_basename() is mostly used on attachment URLs in core, which is why, I guess, we didn't catch this earlier.
comment:3
SergeyBiryukov
— 8 months ago
- Summary changed from wp_basname wrong on Windows Systems to wp_basename wrong on Windows Systems
comment:6
bpetty
— 8 months ago
- Keywords needs-unit-tests removed
I added unit tests for wp_basename for this situation.
comment:7
bpetty
— 8 months ago
Obviously, I also tested, and [attachement:22138.patch] works.
comment:10
ryan
— 8 months ago
- Owner set to ryan
- Resolution set to fixed
- Status changed from new to closed
In [22310]:
Possible Resolution:
function wp_basename( $path, $suffix = '' ) { $path = str_replace( '\', '/', $path ); $path = str_replace( '%2F', '/', urlencode( $path ) ); return urldecode( basename( $path ), $suffix ); }