From 63c9b1f0515c60c942815b1f0165684a466c3008 Mon Sep 17 00:00:00 2001 From: K Adam White Date: Mon, 31 Oct 2022 16:47:08 -0400 Subject: [PATCH 1/2] Improve support for special characters in blognames image 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 --- providers/class.two-factor-email.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/class.two-factor-email.php b/providers/class.two-factor-email.php index 17788571..775223d0 100644 --- a/providers/class.two-factor-email.php +++ b/providers/class.two-factor-email.php @@ -148,7 +148,7 @@ public function generate_and_email_token( $user ) { $token = $this->generate_token( $user->ID ); /* 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' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ) ); /* translators: %s: token */ $message = wp_strip_all_tags( sprintf( __( 'Enter %s to log in.', 'two-factor' ), $token ) ); From d3c2bab17cc47f7cefe3612fc606bfa0cae8997d Mon Sep 17 00:00:00 2001 From: "Alexis J. Villegas" <14046668+ajvillegas@users.noreply.github.com> Date: Thu, 12 Jan 2023 19:20:24 -0400 Subject: [PATCH 2/2] Use mb_encode_mimeheader() for AWS compatibility --- providers/class.two-factor-email.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/class.two-factor-email.php b/providers/class.two-factor-email.php index 775223d0..cac57580 100644 --- a/providers/class.two-factor-email.php +++ b/providers/class.two-factor-email.php @@ -148,7 +148,7 @@ public function generate_and_email_token( $user ) { $token = $this->generate_token( $user->ID ); /* translators: %s: site name */ - $subject = wp_strip_all_tags( sprintf( __( 'Your login confirmation code for %s', 'two-factor' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ) ); + $subject = wp_strip_all_tags( sprintf( __( 'Your login confirmation code for %s', 'two-factor' ), mb_encode_mimeheader( get_option( 'blogname' ), ENT_QUOTES ) ) ); /* translators: %s: token */ $message = wp_strip_all_tags( sprintf( __( 'Enter %s to log in.', 'two-factor' ), $token ) );