Opened 10 years ago
Closed 6 years ago
#33787 closed defect (bug) (worksforme)
Euro hex code being converted to smiley url
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.2 |
Component: | Emoji | Keywords: | has-patch needs-unit-tests |
Focuses: | Cc: |
Description
While using a hex code for euro symbol "€" in a HTML email, wp_staticize_emoji_for_email
filter tries to convert it into a smiley url, which doesn't exist, and the symbol appears broken in the email.
To test this out, here is a small plugin.
Updating the regex in /wp-includes/formatting.php
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/formatting.php#L4530, fixes the issue.
Attachments (4)
Change History (9)
#1
@
10 years ago
- Component changed from Mail to Formatting
- Keywords has-patch needs-unit-tests added
- Milestone changed from Awaiting Review to Future Release
- Summary changed from Euro hex code being converted to smiley url in html email to Euro hex code being converted to smiley url
- Version changed from 4.3 to 4.2
Thanks for the patch, Umesh!
This affects any text that gets passed through wp_staticize_emoji()
, including HTML emails and post content in RSS feeds.
The wp_staticize_emoji()
function needs unit tests.
#3
@
10 years ago
Good times.
Ideally, we should be using the same regex as in twemoji.js
, but PHP only supports the \u
style code points from PHP 7.
Writing something to convert the regex to \x
notation isn't too tricky, but there aren't any options for keeping them is sync that excite me.
@azaozz - Do you have thoughts on syncing methods?
#4
@
10 years ago
Ideally, we should be using the same regex as in twemoji.js
You mean this one: https://github.com/twitter/twemoji/blob/gh-pages/twemoji.js#L236? It is generated from http://www.unicode.org/Public/UNIDATA/EmojiSources.txt. We are matching (hex) HTML entities as strings, can probably just get the first column (as array), and do something like:
'/&#x(' . implode( '|', $codepoints ) . ');/i';
However that will generate pretty long regexp. Not sure if PCRE (all the versions used in different PHP versions) is optimized to handle it. We had problems with that in Chrome which were fixed by optimizing the actual regexp (by the browser) before running it.
#5
@
6 years ago
- Component changed from Formatting to Emoji
- Resolution set to worksforme
- Status changed from new to closed
wp_staticize_emoji_for_email()
was fixed ages ago, it now correctly replaces based on the list of emoji that Twemoji supports.
I've confirmed that the original bug no longer occurs.
Updated regex to match the emoji hex code