[wp-trac] [WordPress Trac] #55949: Prevent trailingslashit from removing backslash for valid filenames on linux systems

WordPress Trac noreply at wordpress.org
Wed Jun 8 12:09:44 UTC 2022


#55949: Prevent trailingslashit from removing backslash for valid filenames on
linux systems
--------------------------+-----------------------------
 Reporter:  ReneHermi     |      Owner:  (none)
     Type:  defect (bug)  |     Status:  assigned
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Formatting    |    Version:  6.0
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/55949>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list