diff --git a/index.php b/index.php index a6a6eb6..b6f7dcd 100644 --- a/index.php +++ b/index.php @@ -12,16 +12,27 @@

Email Obfuscator

+ + +

This is obfuscated email:


'some-class', 'id' => 'some-id', 'noscript' => 'Custom noscript contents']); + $email2 = obfuscate_email($email, 'Contact us', ['class' => 'some-class', 'id' => 'some-id', 'noscript' => 'Custom noscript contents']); ?>

This is obfuscated email:

+
+ false]); + ?> +

This is obfuscated email:

+
diff --git a/src/EmailObfuscator.php b/src/EmailObfuscator.php index f509b9c..b658a64 100644 --- a/src/EmailObfuscator.php +++ b/src/EmailObfuscator.php @@ -19,11 +19,12 @@ public static function obfuscate($email, $text = null, $options = []) { $defaults = [ 'noscript' => 'Enable JavaScript to see this email address', + 'mailto' => true, ]; $options = array_merge($defaults, $options); $email = strtolower($email); $coded = ''; - $unmixedkey = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.@-'; + $unmixedkey = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.@-_+%'; $inprogresskey = $unmixedkey; $mixedkey = ''; $unshuffled = strlen($unmixedkey); @@ -62,6 +63,7 @@ public static function obfuscate($email, $text = null, $options = []) } $attrs .= " {$k}=\"{$v}\""; } + $mailto = $options['mailto'] ? 'true' : 'false'; $javascript = <<