Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/email-encoder-bundle/core/includes/classes/class-email-encoder-bundle-helpers.php
+++ b/email-encoder-bundle/core/includes/classes/class-email-encoder-bundle-helpers.php
@@ -189,7 +189,7 @@
*/
public function parse_html_attributes( string $text ) {
- $attributes = shortcode_parse_atts( $text );
+ $attributes = $this->parse_atts_literal( $text );
// if( is_array( $attributes ) ) {
foreach( $attributes as $ak => $av ){
@@ -198,7 +198,7 @@
$ident = '@';
if( substr( $av, 0, strlen( $ident ) ) === $ident ){
$validated_attribute = substr( $av, strlen( $ident ) );
- $new_attr = shortcode_parse_atts( $validated_attribute );
+ $new_attr = $this->parse_atts_literal( $validated_attribute );
// if( is_array( $new_attr ) ){
foreach( $new_attr as $nak => $nav ){
@@ -230,6 +230,21 @@
}
/**
+ * shortcode_parse_atts() without its C-style unescaping
+ *
+ * shortcode_parse_atts() decodes C-style escapes in every value (plain stripcslashes()
+ * before WordPress 7.1.5), so the text x22 in page HTML, which KSES lets through in
+ * comments, came back as a real double quote. Doubling the backslashes first makes the
+ * decoding return the value exactly as written.
+ *
+ * @param string $text
+ * @return array<int|string, string>
+ */
+ private function parse_atts_literal( string $text ) {
+ return shortcode_parse_atts( str_replace( '\', '\\', $text ) );
+ }
+
+ /**
* Sanitize a string of HTML attributes
*
* @since 2.1.9
--- a/email-encoder-bundle/email-encoder-bundle.php
+++ b/email-encoder-bundle/email-encoder-bundle.php
@@ -1,7 +1,7 @@
<?php
/**
* Plugin Name: Email Encoder - Protect Email Addresses
- * Version: 2.5.5
+ * Version: 2.5.6
* Requires PHP: 7.4
* Plugin URI: https://wpemailencoder.com/
* Description: Protect email addresses on your site and hide them from spambots. Easy to use & flexible.
@@ -19,7 +19,7 @@
defined( 'ABSPATH' ) || exit;
define( 'EEB_NAME', 'Email Encoder' );
-define( 'EEB_VERSION', '2.5.5' );
+define( 'EEB_VERSION', '2.5.6' );
define( 'EEB_SETUP', true );
define( 'EEB_PLUGIN_FILE', __FILE__ );
define( 'EEB_PLUGIN_BASE', plugin_basename( EEB_PLUGIN_FILE ) );
--- a/email-encoder-bundle/src/Validate/Encoding.php
+++ b/email-encoder-bundle/src/Validate/Encoding.php
@@ -113,11 +113,12 @@
. '<script type="text/javascript">'
. 'document.getElementById("' . $element_id . '").innerHTML = decodeURIComponent("';
- if ( is_array( $split ) )
- foreach ( $split as $c ) {
- // preg split will return empty first and last characters, check for them and ignore
- if ( ! empty( $c ) || $c === '0' ) {
- $out .= '%' . dechex( ord( $c ) );
+ if ( is_array( $split ) ) {
+ foreach ( $split as $c ) {
+ // preg split will return empty first and last characters, check for them and ignore
+ if ( ! empty( $c ) || $c === '0' ) {
+ $out .= '%' . dechex( ord( $c ) );
+ }
}
}
@@ -243,7 +244,10 @@
foreach ( $attrs as $key => $value ) {
if ( strtolower( $key ) === 'href' ) {
if ( $protection_method === 'without_javascript' ) {
- $link .= $key . '="' . antispambot( $value ) . '" ';
+ // antispambot() only obfuscates: it leaves about half the characters raw,
+ // a quote included, so the result still needs esc_attr() (which keeps its
+ // &#NN; entities as they are).
+ $link .= 'href="' . esc_attr( antispambot( $value ) ) . '" ';
} else {
$encoded_email = $this->get_encoded_email( $email );
@@ -266,7 +270,7 @@
// When the display holds richer content (e.g. a builder-wrapped <span>Email us at x</span>),
// keep the markup intact — the final filterPlainEmails pass below entity-encodes any emails
// still embedded in it so bots can't harvest them.
- $display_is_just_email = ( $email !== '' && trim( strip_tags( (string) $display ) ) === $email );
+ $display_is_just_email = ( $email !== '' && trim( wp_strip_all_tags( (string) $display ) ) === $email );
if ( $display_is_just_email && trim( (string) $display ) !== $email ) {
// The email is wrapped in markup, e.g. Elementor's icon list:
@@ -344,7 +348,8 @@
foreach ( $attrs as $key => $value ) {
if ( strtolower( $key ) === 'href' ) {
- $link .= $key . '="' . antispambot( $value ) . '" ';
+ // antispambot() is not an escaper (see create_protected_mailto()).
+ $link .= 'href="' . esc_attr( antispambot( $value ) ) . '" ';
} else {
$link .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" ';
}
--- a/email-encoder-bundle/src/Validate/Filters.php
+++ b/email-encoder-bundle/src/Validate/Filters.php
@@ -335,7 +335,7 @@
$attr_name = trim( $s_attr );
$callbackEncodeCustomLinks = function ( $match ) use ( $self, $protection_method ) {
- $attrs = shortcode_parse_atts( $match[1] );
+ $attrs = $this->helper()->parse_html_attributes( $match[1] );
return $self->createProtectedHrefAtt( $match[4], $attrs, $protection_method );
};
--- a/email-encoder-bundle/templates/widgets/main.php
+++ b/email-encoder-bundle/templates/widgets/main.php
@@ -168,13 +168,13 @@
?>
<div class="eeb-setting eeb-setting--text">
<div class="eeb-setting-header">
- <h4><label for="<?php echo $text_id; ?>"><?php echo wp_kses_post( $data['label'] ); ?></label></h4>
+ <h4><label for="<?php echo esc_attr( $text_id ); ?>"><?php echo wp_kses_post( $data['label'] ); ?></label></h4>
<?php if ( isset( $data['description'] ) ) : ?>
<p class="eeb-setting-sublabel"><?php echo wp_kses_post( $data['description'] ); ?></p>
<?php endif; ?>
</div>
<div class="eeb-setting-body">
- <input id="<?php echo $text_id; ?>"
+ <input id="<?php echo esc_attr( $text_id ); ?>"
name="<?php echo esc_attr( $this->getSettingsKey() ); ?>[<?php echo esc_attr( $si_name ); ?>]"
type="text"
class="eeb-input"
@@ -186,8 +186,8 @@
$option_id = esc_attr( $si_name . '_' . $si_key );
$icon = ! empty( $data['icon'] ) ? $data['icon'] : 'marker';
?>
- <label class="eeb-radio-card" for="<?php echo $option_id; ?>">
- <input id="<?php echo $option_id; ?>"
+ <label class="eeb-radio-card" for="<?php echo esc_attr( $option_id ); ?>">
+ <input id="<?php echo esc_attr( $option_id ); ?>"
class="eeb-radio-card-input"
name="<?php echo esc_attr( $this->getSettingsKey() ); ?>[<?php echo esc_attr( $si_name ); ?>]"
type="radio"
@@ -213,7 +213,7 @@
$option_id = esc_attr( $si_name . '_' . $si_key );
?>
<div class="eeb-option-row">
- <label for="<?php echo $option_id; ?>" class="eeb-option-label">
+ <label for="<?php echo esc_attr( $option_id ); ?>" class="eeb-option-label">
<?php echo wp_kses_post( $data['label'] ); ?>
</label>
<?php if ( isset( $data['description'] ) ) : ?>
@@ -222,10 +222,10 @@
<span class="eeb-tooltip-text"><?php echo esc_html( wp_strip_all_tags( $data['description'] ) ); ?></span>
</span>
<?php endif; ?>
- <label class="eeb-option" for="<?php echo $option_id; ?>">
+ <label class="eeb-option" for="<?php echo esc_attr( $option_id ); ?>">
<?php // Hidden zero submits when checkbox is unchecked, so the saved option always reflects the toggle state. ?>
<input type="hidden" name="<?php echo esc_attr( $this->getSettingsKey() ); ?>[<?php echo esc_attr( $si_name ); ?>]" value="0" />
- <input id="<?php echo $option_id; ?>"
+ <input id="<?php echo esc_attr( $option_id ); ?>"
name="<?php echo esc_attr( $this->getSettingsKey() ); ?>[<?php echo esc_attr( $si_name ); ?>]"
type="checkbox"
value="<?php echo esc_attr( $mi_value ); ?>"
--- a/email-encoder-bundle/vendor/composer/installed.php
+++ b/email-encoder-bundle/vendor/composer/installed.php
@@ -3,7 +3,7 @@
'name' => 'onlineoptimisation/email-encoder-bundle',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
- 'reference' => '564ae76e0d735684be45c165ac27063c0bd33f9c',
+ 'reference' => 'b51e8324de4a8f529fc84764ab4821feb6be0dfc',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -13,7 +13,7 @@
'onlineoptimisation/email-encoder-bundle' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
- 'reference' => '564ae76e0d735684be45c165ac27063c0bd33f9c',
+ 'reference' => 'b51e8324de4a8f529fc84764ab4821feb6be0dfc',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),