Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#55949 assigned defect (bug)

Prevent trailingslashit from removing backslash for valid filenames on linux systems

Reported by: renehermi's profile ReneHermi Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 6.0
Component: Formatting Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

On *nix systems, a file or folder name can contain a backslash like document.pdf\ or folder-name\.

trailingslashit() as it is currently removes the backslash and breaks the original name of such a file.

This PR fixes this issue and keeps the backslash character on *nix systems.
On Windows systems this PR will not change anything**

Yes, this is an edge case and will not happen often but we experienced this issue on a real case on one of our clients who had a folder name with a backlash at the end.

trailingslashit() broke this folder name and we had to create our own version of trailingslashit() to get around this problem.

I don't like much the extra complexity that my solution adds to a function that exists for more than 8 years in its current form. So if you have a better idea or opinin, let's discuss this.

GitHub https://github.com/WordPress/wordpress-develop/pull/2796

Change History (1)

This ticket was mentioned in PR #2796 on WordPress/wordpress-develop by rene-hermenau.


3 years ago
#1

  • Keywords has-patch has-unit-tests added

On *nix systems, a file or folder name can contain a backslash like document.pdf\ or folder-name\

trailingslashit() in its current form removes the backslash and breaks the original name of such a file.

This PR fixes this issue and keeps the backslash character on *nix systems.

On Windows systems this PR will not change anything.

Trac Ticket: https://core.trac.wordpress.org/ticket/55949#ticket

Trac ticket:

Note: See TracTickets for help on using tickets.