Skip to content

Commit

Permalink
= 4.2.7.4 =
Browse files Browse the repository at this point in the history
~ Revert code mb_convert_encoding deprecated of Emogrifier class.
  • Loading branch information
tungnxt89 committed Nov 18, 2024
1 parent bd701e8 commit 3433e83
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions inc/libraries/class-emogrifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,11 @@ public function emogrify() {
$this->copyCssWithMediaToStyleNode( $cssParts, $xmlDocument );

if ( $this->preserveEncoding ) {
return htmlspecialchars_decode( utf8_encode( html_entity_decode( $xmlDocument->saveHTML(), ENT_COMPAT, self::ENCODING ) ) );
if ( function_exists( 'mb_convert_encoding' ) ) {
return mb_convert_encoding( $xmlDocument->saveHTML(), self::ENCODING, 'HTML-ENTITIES' );
} else {
return htmlspecialchars_decode( utf8_encode( html_entity_decode( $xmlDocument->saveHTML(), ENT_COMPAT, self::ENCODING ) ) );
}
} else {
return $xmlDocument->saveHTML();
}
Expand Down Expand Up @@ -526,8 +530,11 @@ private function getUnifiedHtml() {
$bodyWithoutUnprocessableTags = $this->html;
}


return htmlspecialchars_decode( utf8_decode( htmlentities( $bodyWithoutUnprocessableTags, ENT_COMPAT, self::ENCODING, false ) ) );
if ( function_exists( 'mb_convert_encoding' ) ) {
return mb_convert_encoding( $bodyWithoutUnprocessableTags, 'HTML-ENTITIES', self::ENCODING );
} else {
return htmlspecialchars_decode( utf8_decode( htmlentities( $bodyWithoutUnprocessableTags, ENT_COMPAT, self::ENCODING, false ) ) );
}
}

/**
Expand Down Expand Up @@ -660,10 +667,10 @@ private function matchIdAttributes( array $match ) {
*/
private function matchClassAttributes( array $match ) {
return ( strlen( $match[1] ) ? $match[1] : '*' ) . '[contains(concat(" ",@class," "),concat(" ","' .
implode(
'"," "))][contains(concat(" ",@class," "),concat(" ","',
explode( '.', substr( $match[2], 1 ) )
) . '"," "))]';
implode(
'"," "))][contains(concat(" ",@class," "),concat(" ","',
explode( '.', substr( $match[2], 1 ) )
) . '"," "))]';
}

/**
Expand Down

0 comments on commit 3433e83

Please sign in to comment.