Version Description
- Prevented error when
eae_encode_emails()
doesn't receive astring
Download this release
Release Info
Developer | tillkruess |
Plugin | Email Address Encoder |
Version | 1.0.5 |
Comparing to | |
See all releases |
Code changes from version 1.0.4 to 1.0.5
- email-address-encoder.php +34 -45
- languages/email-address-encoder.pot +36 -0
- readme.txt +14 -6
email-address-encoder.php
CHANGED
@@ -3,46 +3,30 @@
|
|
3 |
Plugin Name: Email Address Encoder
|
4 |
Plugin URI: http://wordpress.org/plugins/email-address-encoder/
|
5 |
Description: A lightweight plugin to protect email addresses from email-harvesting robots by encoding them into decimal and hexadecimal entities.
|
6 |
-
Version: 1.0.
|
7 |
Author: Till Krüss
|
8 |
-
Author URI:
|
9 |
Text Domain: email-address-encoder
|
|
|
10 |
License: GPLv3
|
11 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
12 |
*/
|
13 |
|
14 |
-
|
15 |
-
* Copyright 2014 Till Krüss (http://till.kruss.me/)
|
16 |
-
*
|
17 |
-
* This program is free software: you can redistribute it and/or modify
|
18 |
-
* it under the terms of the GNU General Public License as published by
|
19 |
-
* the Free Software Foundation, either version 3 of the License, or
|
20 |
-
* (at your option) any later version.
|
21 |
-
*
|
22 |
-
* This program is distributed in the hope that it will be useful,
|
23 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
24 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
25 |
-
* GNU General Public License for more details.
|
26 |
-
*
|
27 |
-
* You should have received a copy of the GNU General Public License
|
28 |
-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
29 |
-
*
|
30 |
-
* @package Email Address Encoder
|
31 |
-
* @copyright 2014 Till Krüss
|
32 |
-
*/
|
33 |
|
34 |
/**
|
35 |
-
* Define
|
36 |
*/
|
37 |
-
if (!defined('EAE_FILTER_PRIORITY'))
|
38 |
-
define('EAE_FILTER_PRIORITY', 1000);
|
|
|
39 |
|
40 |
/**
|
41 |
-
* Register filters to encode
|
42 |
-
*
|
43 |
*/
|
44 |
-
foreach (array('the_content', 'the_excerpt', 'widget_text', 'comment_text', 'comment_excerpt') as $filter) {
|
45 |
-
add_filter($filter, 'eae_encode_emails', EAE_FILTER_PRIORITY);
|
46 |
}
|
47 |
|
48 |
/**
|
@@ -55,15 +39,20 @@ foreach (array('the_content', 'the_excerpt', 'widget_text', 'comment_text', 'com
|
|
55 |
* @param string $string Text with email addresses to encode
|
56 |
* @return string $string Given text with encoded email addresses
|
57 |
*/
|
58 |
-
function eae_encode_emails($string) {
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
-
// abort if
|
61 |
-
if (apply_filters('eae_at_sign_check', true)) {
|
62 |
-
|
63 |
}
|
64 |
|
65 |
// override encoding function with the 'eae_method' filter
|
66 |
-
$method = apply_filters('eae_method', 'eae_encode_str');
|
67 |
|
68 |
// override regex pattern with the 'eae_regexp' filter
|
69 |
$regexp = apply_filters(
|
@@ -88,7 +77,7 @@ function eae_encode_emails($string) {
|
|
88 |
$regexp,
|
89 |
create_function(
|
90 |
'$matches',
|
91 |
-
'return '
|
92 |
),
|
93 |
$string
|
94 |
);
|
@@ -110,27 +99,27 @@ function eae_encode_emails($string) {
|
|
110 |
* @param string $string Text with email addresses to encode
|
111 |
* @return string $string Given text with encoded email addresses
|
112 |
*/
|
113 |
-
function eae_encode_str($string) {
|
114 |
|
115 |
-
$chars = str_split($string);
|
116 |
-
$seed = mt_rand(0, (int) abs(crc32($string) / strlen($string)));
|
117 |
|
118 |
-
foreach ($chars as $key => $char) {
|
119 |
|
120 |
-
$ord = ord($char);
|
121 |
|
122 |
-
if ($ord < 128) { // ignore non-ascii chars
|
123 |
|
124 |
-
$r = ($seed * (1 + $key)) % 100; // pseudo "random function"
|
125 |
|
126 |
-
if ($r > 60 && $char != '@') ; // plain character (not encoded), if not @-sign
|
127 |
-
else if ($r < 45) $chars[$key] = '&#x'.dechex($ord).';'; // hexadecimal
|
128 |
-
else $chars[$key] = '&#'
|
129 |
|
130 |
}
|
131 |
|
132 |
}
|
133 |
|
134 |
-
return implode('', $chars);
|
135 |
|
136 |
}
|
3 |
Plugin Name: Email Address Encoder
|
4 |
Plugin URI: http://wordpress.org/plugins/email-address-encoder/
|
5 |
Description: A lightweight plugin to protect email addresses from email-harvesting robots by encoding them into decimal and hexadecimal entities.
|
6 |
+
Version: 1.0.5
|
7 |
Author: Till Krüss
|
8 |
+
Author URI: https://till.im/
|
9 |
Text Domain: email-address-encoder
|
10 |
+
Domain Path: /languages
|
11 |
License: GPLv3
|
12 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
13 |
*/
|
14 |
|
15 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
/**
|
18 |
+
* Define default filter-priority constant, unless it has already been defined.
|
19 |
*/
|
20 |
+
if ( ! defined( 'EAE_FILTER_PRIORITY' ) ) {
|
21 |
+
define( 'EAE_FILTER_PRIORITY', 1000 );
|
22 |
+
}
|
23 |
|
24 |
/**
|
25 |
+
* Register filters to encode plain email addresses in posts, pages, excerpts,
|
26 |
+
* comments and text widgets.
|
27 |
*/
|
28 |
+
foreach ( array( 'the_content', 'the_excerpt', 'widget_text', 'comment_text', 'comment_excerpt' ) as $filter ) {
|
29 |
+
add_filter( $filter, 'eae_encode_emails', EAE_FILTER_PRIORITY );
|
30 |
}
|
31 |
|
32 |
/**
|
39 |
* @param string $string Text with email addresses to encode
|
40 |
* @return string $string Given text with encoded email addresses
|
41 |
*/
|
42 |
+
function eae_encode_emails( $string ) {
|
43 |
+
|
44 |
+
// abort if `$string` isn't a string
|
45 |
+
if ( ! is_string( $string ) ) {
|
46 |
+
return $string;
|
47 |
+
}
|
48 |
|
49 |
+
// abort if `eae_at_sign_check` is true and `$string` doesn't contain a @-sign
|
50 |
+
if ( apply_filters( 'eae_at_sign_check', true ) && strpos( $string, '@' ) === false ) {
|
51 |
+
return $string;
|
52 |
}
|
53 |
|
54 |
// override encoding function with the 'eae_method' filter
|
55 |
+
$method = apply_filters( 'eae_method', 'eae_encode_str' );
|
56 |
|
57 |
// override regex pattern with the 'eae_regexp' filter
|
58 |
$regexp = apply_filters(
|
77 |
$regexp,
|
78 |
create_function(
|
79 |
'$matches',
|
80 |
+
'return ' . $method . '($matches[0]);'
|
81 |
),
|
82 |
$string
|
83 |
);
|
99 |
* @param string $string Text with email addresses to encode
|
100 |
* @return string $string Given text with encoded email addresses
|
101 |
*/
|
102 |
+
function eae_encode_str( $string ) {
|
103 |
|
104 |
+
$chars = str_split( $string );
|
105 |
+
$seed = mt_rand( 0, (int) abs( crc32( $string ) / strlen( $string ) ) );
|
106 |
|
107 |
+
foreach ( $chars as $key => $char ) {
|
108 |
|
109 |
+
$ord = ord( $char );
|
110 |
|
111 |
+
if ( $ord < 128 ) { // ignore non-ascii chars
|
112 |
|
113 |
+
$r = ( $seed * ( 1 + $key ) ) % 100; // pseudo "random function"
|
114 |
|
115 |
+
if ( $r > 60 && $char != '@' ) ; // plain character (not encoded), if not @-sign
|
116 |
+
else if ( $r < 45 ) $chars[ $key ] = '&#x' . dechex( $ord ) . ';'; // hexadecimal
|
117 |
+
else $chars[ $key ] = '&#' . $ord . ';'; // decimal (ascii)
|
118 |
|
119 |
}
|
120 |
|
121 |
}
|
122 |
|
123 |
+
return implode( '', $chars );
|
124 |
|
125 |
}
|
languages/email-address-encoder.pot
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (C) 2016 Email Address Encoder
|
2 |
+
# This file is distributed under the same license as the Email Address Encoder package.
|
3 |
+
msgid ""
|
4 |
+
msgstr ""
|
5 |
+
"Project-Id-Version: Email Address Encoder 1.0.5\n"
|
6 |
+
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/email-address-"
|
7 |
+
"encoder\n"
|
8 |
+
"POT-Creation-Date: 2016-05-02 16:21:44+00:00\n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"PO-Revision-Date: 2016-MO-DA HO:MI+ZONE\n"
|
13 |
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 |
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
15 |
+
|
16 |
+
#. Plugin Name of the plugin/theme
|
17 |
+
msgid "Email Address Encoder"
|
18 |
+
msgstr ""
|
19 |
+
|
20 |
+
#. Plugin URI of the plugin/theme
|
21 |
+
msgid "http://wordpress.org/plugins/email-address-encoder/"
|
22 |
+
msgstr ""
|
23 |
+
|
24 |
+
#. Description of the plugin/theme
|
25 |
+
msgid ""
|
26 |
+
"A lightweight plugin to protect email addresses from email-harvesting robots "
|
27 |
+
"by encoding them into decimal and hexadecimal entities."
|
28 |
+
msgstr ""
|
29 |
+
|
30 |
+
#. Author of the plugin/theme
|
31 |
+
msgid "Till Krüss"
|
32 |
+
msgstr ""
|
33 |
+
|
34 |
+
#. Author URI of the plugin/theme
|
35 |
+
msgid "https://till.im/"
|
36 |
+
msgstr ""
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: tillkruess
|
|
3 |
Donate link: https://www.paypal.me/tillkruss
|
4 |
Tags: antispam, anti spam, spam, email, e-mail, mail, spider, crawler, harvester, robots, spambot, block, obfuscate, obfuscation, encode, encoder, encoding, encrypt, encryption, protect, protection
|
5 |
Requires at least: 2.0
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.0.
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -51,9 +51,9 @@ This plugin doesn't encode the entire website for performance reasons, it encode
|
|
51 |
|
52 |
You can override [the pattern](http://fightingforalostcause.net/misc/2006/compare-email-regex.php "Comparing E-mail Address Validating Regular Expressions") with the `eae_regexp` filter: `add_filter( 'eae_regexp', function () { return '/^pattern$/'; } );`
|
53 |
|
54 |
-
= How can I change the
|
55 |
|
56 |
-
The default filter
|
57 |
|
58 |
= How can I disable the @-sign check? =
|
59 |
|
@@ -62,9 +62,13 @@ Like this: `add_filter( 'eae_at_sign_check', '__return_false' );`
|
|
62 |
|
63 |
== Changelog ==
|
64 |
|
|
|
|
|
|
|
|
|
65 |
= 1.0.4 =
|
66 |
|
67 |
-
* Added `EAE_FILTER_PRIORITY` constant to adjust default filter
|
68 |
|
69 |
= 1.0.3 =
|
70 |
|
@@ -87,9 +91,13 @@ Like this: `add_filter( 'eae_at_sign_check', '__return_false' );`
|
|
87 |
|
88 |
== Upgrade Notice ==
|
89 |
|
|
|
|
|
|
|
|
|
90 |
= 1.0.4 =
|
91 |
|
92 |
-
Added constant to adjust default filter
|
93 |
|
94 |
= 1.0.3 =
|
95 |
|
3 |
Donate link: https://www.paypal.me/tillkruss
|
4 |
Tags: antispam, anti spam, spam, email, e-mail, mail, spider, crawler, harvester, robots, spambot, block, obfuscate, obfuscation, encode, encoder, encoding, encrypt, encryption, protect, protection
|
5 |
Requires at least: 2.0
|
6 |
+
Tested up to: 4.9
|
7 |
+
Stable tag: 1.0.5
|
8 |
License: GPLv3
|
9 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
51 |
|
52 |
You can override [the pattern](http://fightingforalostcause.net/misc/2006/compare-email-regex.php "Comparing E-mail Address Validating Regular Expressions") with the `eae_regexp` filter: `add_filter( 'eae_regexp', function () { return '/^pattern$/'; } );`
|
53 |
|
54 |
+
= How can I change the priority of the default filters? =
|
55 |
|
56 |
+
The default filter priority is `1000` and you can adjust it by defining the `EAE_FILTER_PRIORITY` constant: `define( 'EAE_FILTER_PRIORITY', 99999 );`. The constant has to be defined before this plugin is loaded, e.g. in your `wp-config.php` or in Must-use plugin (a.k.a. mu-plugin).
|
57 |
|
58 |
= How can I disable the @-sign check? =
|
59 |
|
62 |
|
63 |
== Changelog ==
|
64 |
|
65 |
+
= 1.0.5 =
|
66 |
+
|
67 |
+
* Prevented error when `eae_encode_emails()` doesn't receive a `string`
|
68 |
+
|
69 |
= 1.0.4 =
|
70 |
|
71 |
+
* Added `EAE_FILTER_PRIORITY` constant to adjust default filter priority
|
72 |
|
73 |
= 1.0.3 =
|
74 |
|
91 |
|
92 |
== Upgrade Notice ==
|
93 |
|
94 |
+
= 1.0.5 =
|
95 |
+
|
96 |
+
This update includes a minor bug fix.
|
97 |
+
|
98 |
= 1.0.4 =
|
99 |
|
100 |
+
Added constant to adjust default filter priority.
|
101 |
|
102 |
= 1.0.3 =
|
103 |
|