Email Encoder Bundle – Protect Email Address - Version 2.0.4

Version Description

  • Feature: Exclude script tags from being encoded
  • Fix: Revalidate and strip escape sequences for encode_escape function
  • Fix: Return shortcode content of eeb_mailto instead of outputting it
Download this release

Release Info

Developer ironikus
Plugin Icon 128x128 Email Encoder Bundle – Protect Email Address
Version 2.0.4
Comparing to
See all releases

Code changes from version 2.0.3 to 2.0.4

core/includes/classes/class-email-encoder-bundle-settings.php CHANGED
@@ -45,6 +45,7 @@ class Email_Encoder_Settings{
45
  $this->settings_key = 'WP_Email_Encoder_Bundle_options';
46
  $this->version_key = 'email-encoder-bundle-version';
47
  $this->image_secret_key = 'email-encoder-bundle-img-key';
 
48
  $this->previous_version = null;
49
  $this->hook_priorities = array(
50
  'buffer_final_output' => 1000,
@@ -191,6 +192,11 @@ class Email_Encoder_Settings{
191
  'label' => __( 'mailto links without CSS direction', 'email-encoder-bundle' ),
192
  'description' => __( 'Check this option if your site does not support CSS directions.', 'email-encoder-bundle' )
193
  ),
 
 
 
 
 
194
  ),
195
  'required' => false,
196
  ),
@@ -641,6 +647,15 @@ class Email_Encoder_Settings{
641
  return apply_filters( 'eeb/settings/final_outout_buffer_hook', $this->final_outout_buffer_hook );
642
  }
643
 
 
 
 
 
 
 
 
 
 
644
  /**
645
  * @link http://www.mkyong.com/regular-expressions/how-to-validate-email-address-with-regular-expression/
646
  * @param boolean $include
45
  $this->settings_key = 'WP_Email_Encoder_Bundle_options';
46
  $this->version_key = 'email-encoder-bundle-version';
47
  $this->image_secret_key = 'email-encoder-bundle-img-key';
48
+ $this->at_identifier = '##eebAddIdent##';
49
  $this->previous_version = null;
50
  $this->hook_priorities = array(
51
  'buffer_final_output' => 1000,
192
  'label' => __( 'mailto links without CSS direction', 'email-encoder-bundle' ),
193
  'description' => __( 'Check this option if your site does not support CSS directions.', 'email-encoder-bundle' )
194
  ),
195
+ 'no_script_tags' => array(
196
+ 'advanced' => true,
197
+ 'label' => __( 'no script tags', 'email-encoder-bundle' ),
198
+ 'description' => __( 'Check this option if you face issues with encoded script tags. This will deactivate protection for script tags.', 'email-encoder-bundle' )
199
+ ),
200
  ),
201
  'required' => false,
202
  ),
647
  return apply_filters( 'eeb/settings/final_outout_buffer_hook', $this->final_outout_buffer_hook );
648
  }
649
 
650
+ /**
651
+ * Return the @ symbol identifier
652
+ *
653
+ * @return string - the @ symbol identifier
654
+ */
655
+ public function get_at_identifier(){
656
+ return apply_filters( 'eeb/settings/at_identifier', $this->at_identifier );
657
+ }
658
+
659
  /**
660
  * @link http://www.mkyong.com/regular-expressions/how-to-validate-email-address-with-regular-expression/
661
  * @param boolean $include
core/includes/classes/class-email-encoder-bundle-validate.php CHANGED
@@ -36,6 +36,7 @@ class Email_Encoder_Validate{
36
  $this->page_name = EEB()->settings->get_page_name();
37
  $this->page_title = EEB()->settings->get_page_title();
38
  $this->final_outout_buffer_hook = EEB()->settings->get_final_outout_buffer_hook();
 
39
  }
40
 
41
  /**
@@ -83,6 +84,10 @@ class Email_Encoder_Validate{
83
  $filtered_body = $this->filter_content( $filtered_body, $protect_using );
84
 
85
  $filtered_content = $filtered_head . $htmlSplit[1] . $filtered_body;
 
 
 
 
86
  return $filtered_content;
87
  }
88
 
@@ -157,6 +162,9 @@ class Email_Encoder_Validate{
157
  break;
158
  }
159
 
 
 
 
160
  return $filtered;
161
  }
162
 
@@ -318,14 +326,22 @@ class Email_Encoder_Validate{
318
  */
319
  public function filter_soft_dom_attributes( $content, $protection_method ){
320
 
 
 
321
  if( class_exists( 'DOMDocument' ) ){
322
  $dom = new DOMDocument();
323
  @$dom->loadHTML($content);
324
 
325
  //Soft-encode scripts
326
  $script = $dom->getElementsByTagName('script');
327
- foreach($script as $item){
328
- $content = str_replace( $item->nodeValue, $this->filter_plain_emails( $item->nodeValue, null, $protection_method, false ), $content );
 
 
 
 
 
 
329
  }
330
  }
331
 
@@ -340,6 +356,14 @@ class Email_Encoder_Validate{
340
  * ######################
341
  */
342
 
 
 
 
 
 
 
 
 
343
  /**
344
  * ASCII method
345
  *
@@ -404,6 +428,9 @@ class Email_Encoder_Validate{
404
  $element_id = 'eeb-' . mt_rand( 0, 1000000 ) . '-' . mt_rand( 0, 1000000 );
405
  $string = '\'' . $value . '\'';
406
 
 
 
 
407
  // break string into array of characters, we can't use string_split because its php5 only
408
  $split = preg_split( '||', $string );
409
  $out = '<span id="'. $element_id . '"></span>'
36
  $this->page_name = EEB()->settings->get_page_name();
37
  $this->page_title = EEB()->settings->get_page_title();
38
  $this->final_outout_buffer_hook = EEB()->settings->get_final_outout_buffer_hook();
39
+ $this->at_identifier = EEB()->settings->get_at_identifier();
40
  }
41
 
42
  /**
84
  $filtered_body = $this->filter_content( $filtered_body, $protect_using );
85
 
86
  $filtered_content = $filtered_head . $htmlSplit[1] . $filtered_body;
87
+
88
+ //Revalidate filtered emails that should not bbe encoded
89
+ $filtered_content = $this->temp_encode_at_symbol( $filtered_content, true );
90
+
91
  return $filtered_content;
92
  }
93
 
162
  break;
163
  }
164
 
165
+ //Revalidate filtered emails that should not bbe encoded
166
+ $filtered = $this->temp_encode_at_symbol( $filtered, true );
167
+
168
  return $filtered;
169
  }
170
 
326
  */
327
  public function filter_soft_dom_attributes( $content, $protection_method ){
328
 
329
+ $no_script_tags = (bool) EEB()->settings->get_setting( 'no_script_tags', true, 'filter_body' );
330
+
331
  if( class_exists( 'DOMDocument' ) ){
332
  $dom = new DOMDocument();
333
  @$dom->loadHTML($content);
334
 
335
  //Soft-encode scripts
336
  $script = $dom->getElementsByTagName('script');
337
+ if( ! $no_script_tags ){
338
+ foreach($script as $item){
339
+ $content = str_replace( $item->nodeValue, $this->filter_plain_emails( $item->nodeValue, null, $protection_method, false ), $content );
340
+ }
341
+ } else {
342
+ foreach($script as $item){
343
+ $content = str_replace( $item->nodeValue, $this->temp_encode_at_symbol( $item->nodeValue ), $content );
344
+ }
345
  }
346
  }
347
 
356
  * ######################
357
  */
358
 
359
+ public function temp_encode_at_symbol( $content, $decode = false ){
360
+ if( $decode ){
361
+ return str_replace( $this->at_identifier, '@', $content );
362
+ }
363
+
364
+ return str_replace( '@', $this->at_identifier, $content );
365
+ }
366
+
367
  /**
368
  * ASCII method
369
  *
428
  $element_id = 'eeb-' . mt_rand( 0, 1000000 ) . '-' . mt_rand( 0, 1000000 );
429
  $string = '\'' . $value . '\'';
430
 
431
+ //Validate escape sequences
432
+ $string = preg_replace('/\s+/S', " ", $string);
433
+
434
  // break string into array of characters, we can't use string_split because its php5 only
435
  $split = preg_split( '||', $string );
436
  $out = '<span id="'. $element_id . '"></span>'
core/includes/functions/template-tags.php CHANGED
@@ -54,7 +54,7 @@ if (!function_exists('eeb_mailto')):
54
  break;
55
  }
56
 
57
- echo apply_filters( 'eeb/frontend/template_func/eeb_mailto', $mailto );
58
 
59
  }
60
  endif;
54
  break;
55
  }
56
 
57
+ return apply_filters( 'eeb/frontend/template_func/eeb_mailto', $mailto );
58
 
59
  }
60
  endif;
email-encoder-bundle.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * Plugin Name: Email Encoder - Protect Email Addresses
4
- * Version: 2.0.3
5
  * Plugin URI: https://wordpress.org/plugins/email-encoder-bundle/
6
  * Description: Protect email addresses on your site and hide them from spambots. Easy to use & flexible.
7
  * Author: Ironikus
@@ -22,7 +22,7 @@ if ( !defined( 'ABSPATH' ) ) exit;
22
  define( 'EEB_NAME', 'Email Encoder' );
23
 
24
  // Plugin version.
25
- define( 'EEB_VERSION', '2.0.3' );
26
 
27
  // Determines if the plugin is loaded
28
  define( 'EEB_SETUP', true );
1
  <?php
2
  /**
3
  * Plugin Name: Email Encoder - Protect Email Addresses
4
+ * Version: 2.0.4
5
  * Plugin URI: https://wordpress.org/plugins/email-encoder-bundle/
6
  * Description: Protect email addresses on your site and hide them from spambots. Easy to use & flexible.
7
  * Author: Ironikus
22
  define( 'EEB_NAME', 'Email Encoder' );
23
 
24
  // Plugin version.
25
+ define( 'EEB_VERSION', '2.0.4' );
26
 
27
  // Determines if the plugin is loaded
28
  define( 'EEB_SETUP', true );
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: ironikus
3
  Tags: anti spam, protect, encode, encrypt, hide, antispam, mailto, spambot, secure, e-mail, email, mail
4
  Requires at least: 4.7
5
  Requires PHP: 5.1
6
- Tested up to: 5.2.3
7
- Stable tag: 2.0.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -121,6 +121,11 @@ Yes, since version 1.3.0 also special characters are supported.
121
 
122
  == Changelog ==
123
 
 
 
 
 
 
124
  = 2.0.3 =
125
  * Feature: Integration for Divi Theme included
126
  * Tweak: Optimize Jetpack integration to also filter against image attribute description tags
3
  Tags: anti spam, protect, encode, encrypt, hide, antispam, mailto, spambot, secure, e-mail, email, mail
4
  Requires at least: 4.7
5
  Requires PHP: 5.1
6
+ Tested up to: 5.3
7
+ Stable tag: 2.0.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
121
 
122
  == Changelog ==
123
 
124
+ = 2.0.4 =
125
+ * Feature: Exclude script tags from being encoded
126
+ * Fix: Revalidate and strip escape sequences for encode_escape function
127
+ * Fix: Return shortcode content of eeb_mailto instead of outputting it
128
+
129
  = 2.0.3 =
130
  * Feature: Integration for Divi Theme included
131
  * Tweak: Optimize Jetpack integration to also filter against image attribute description tags