[wp-trac] [WordPress Trac] #61182: Normalize UTF-8 charset slug detection.
WordPress Trac
noreply at wordpress.org
Thu May 9 23:04:44 UTC 2024
#61182: Normalize UTF-8 charset slug detection.
-------------------------+--------------------------------------
Reporter: dmsnell | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: 6.6
Component: General | Version: trunk
Severity: normal | Keywords: has-patch has-unit-tests
Focuses: |
-------------------------+--------------------------------------
There are several exist places in Core that attempt to detect if a blog
charset is UTF-8. Each place attempts to perform the same check, except
the logic is spread throughout and there's no single method provided to
make this determination in a consistent way. The _canonical_charset()
method exists, but is marked private for use.
In this patch the new unicode module provides is_utf8_charset() as a
method taking an optional charset slug and indicating if it represents
UTF-8, examining all of the allowable variants of that slug. Associated
code is updated to use this new function, including _canonical_charset().
Finally, the test functions governing _canonical_charset() have been
rewritten as a single test with a data provider instead of as separate
test functions.
This patch raises a couple of questions:
Is there a need to normalize the ISO-8859-1 charsets since
htmlspecialchars() does not need it?
Should WordPress normalize invalid variations of ISO-8859-1, such as
"latin1", so that htmlspecialchars() does not choke?
One important question I'd like your help on, if you know the answer: is
it still important to avoid calling get_option( 'blog_charset' ) multiple
times in a row, or is that already cached? If it's already cached then I
suspect further caching or use of static vars will only bloat the memory
footprint of Core without speeding it up.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61182>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list