[wp-trac] [WordPress Trac] #63585: Common MacOS unicode characters in filenames break
WordPress Trac
noreply at wordpress.org
Tue Jun 17 18:08:18 UTC 2025
#63585: Common MacOS unicode characters in filenames break
--------------------------+-----------------------------
Reporter: matt | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version:
Severity: normal | Keywords: needs-patch
Focuses: |
--------------------------+-----------------------------
When uploading "Screenshot 2025-06-17 at 4.43.59 AM.png", the default
naming for a screenshot in MacOS, I got this error both times. When I
renamed it to "spotlight-with-shortcut.png" it worked fine.
[[Image(https://cldup.com/KSbUmSJdky-2000x2000.png)]]
The URL in the media library was:
https://ma.tt/files/2025/06/Screenshot-2025-06-17-at-5.20.16?PM.png
Which obviously breaks because of the query character.
@zieladam debugged it:
That last space is a Unicode ‘NARROW NO-BREAK SPACE’ (U+202F) – see the
8239 towards the end of the list of codepoints:
{{{
> [..."Screenshot 2025-06-17 at 4.43.59 AM.png"].map(s=>s.codePointAt(0))
(39) [83, 99, 114, 101, 101, 110, 115, 104, 111, 116, 32, 50, 48, 50, 53,
45, 48, 54, 45, 49, 55, 32, 97, 116, 32, 52, 46, 52, 51, 46, 53, 57, 8239,
65, 77, 46, 112, 110, 103]
}}}
I personally would prefer we returned to something along the lines of:
{{{#!php
<?php
remove_accents( $filename );
preg_replace( '/[^a-z0-9 -]/g', '', $filename)
preg_replace( '/\s+/', '-', $filename );
}}}
I don't think there is any huge downside to being very conservative with
uploaded filenames, and it also probably helps with portability if a site
is migrating between different filesystems or OSes. I'm a fan of being
ultra-paranoid any time we write user-supplied data to the filesystem.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63585>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list