Improve support for special characters in blognames#7
Conversation
<img width="235" alt="image" src="https://user-images.githubusercontent.com/442115/199106435-f82bc6d7-51ea-45fe-970d-a62c18a334b7.png"> The emails sent by this plugin mangle the site name of blogs with non-english special characters. I am not confident this fully resolves the issue, because running these two strings via `wp shell` on an environment with a Japanese or accented-french blog name renders the same output, but there is a definite issue with how special characters are handled when sending these emails, and this change mirrors how the wordpress/two-factor plugin does things upstream: https://github.com/WordPress/two-factor/blob/master/providers/class-two-factor-email.php#L227
|
|
||
| /* translators: %s: site name */ | ||
| $subject = wp_strip_all_tags( sprintf( __( 'Your login confirmation code for %s', 'two-factor' ), get_bloginfo( 'name' ) ) ); | ||
| $subject = wp_strip_all_tags( sprintf( __( 'Your login confirmation code for %s', 'two-factor' ), mb_encode_mimeheader( get_option( 'blogname' ), ENT_QUOTES ) ) ); |
There was a problem hiding this comment.
What about html_entity_decode()? Looks fine if it works as expected though.
There was a problem hiding this comment.
I'd defer to @ajvillegas on whether that was tried or not. wp_specialchars_decode which the upstream uses definitely does not fix it, so I would guess that the more specific function here is likely necessary.
|
@roborourke This had worked locally but when I installed on a dev stack just now, I got this fatal when trying to initiate an email code resend: I recommend we untag and un-publish 0.3.1 for now |
|
@kadamwhite The |
|
Reverted in 59b577a and will open a new PR to iterate |
I actually think that this patch doesn't fix my problem, but to report the problem: special characters in the blog name are not properly escaped in the sender field of the email dispatched by this plugin. Example,

The attached change mirrors how the wordpress/two-factor plugin does things upstream:
https://github.com/WordPress/two-factor/blob/master/providers/class-two-factor-email.php#L227
but I assume it would not impact how the blog name is rendered in what I am guessing is the sender name field. So possibly something that needs to be fixed outside of this plugin.