From a0a45f341d8c1e9759feb4ecd45c1311c899d0cc Mon Sep 17 00:00:00 2001 From: "K. Adam White" Date: Mon, 16 Jan 2023 10:12:36 -0500 Subject: [PATCH 1/2] Encode non-ascii characters properly when sending 2fa emails --- 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..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' ), 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 ) ) ); /* translators: %s: token */ $message = wp_strip_all_tags( sprintf( __( 'Enter %s to log in.', 'two-factor' ), $token ) ); From 1cf764c3d02ffaa7bff1ac34c90e3a7a20d4d00b Mon Sep 17 00:00:00 2001 From: "K. Adam White" Date: Mon, 16 Jan 2023 10:16:01 -0500 Subject: [PATCH 2/2] Use UTF-8 as encoding when encoding blogname --- 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 cac57580..ce2d4231 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' ), mb_encode_mimeheader( 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' ), 'UTF-8' ) ) ); /* translators: %s: token */ $message = wp_strip_all_tags( sprintf( __( 'Enter %s to log in.', 'two-factor' ), $token ) );