Added more randomization to safe_email twig filter #998

This commit is contained in:
Andy Miller
2016-08-22 13:45:55 -06:00
parent 5adceea7e9
commit a1039db7af
2 changed files with 9 additions and 4 deletions

View File

@@ -9,6 +9,7 @@
* Added `@page.modular` Collection type [#988](https://github.com/getgrav/grav/issues/988)
* Added support for `self@`, `page@`, `taxonomy@`, `root@` Collection syntax for cleaner YAML compatibility
* Improved GPM commands to allow for `-y` to automate **yes** responses and `-o` for **update** and **selfupgrade** to overwrite installations [#985](https://github.com/getgrav/grav/issues/985)
* Added randomization to `safe_email` Twig filter [#998](https://github.com/getgrav/grav/issues/998)
1. [](#bugfix)
* Fix for lightbox media function throwing error [#981](https://github.com/getgrav/grav/issues/981)
* Removed 307 redirect code option as it is not well supported [#743](https://github.com/getgrav/grav-plugin-admin/issues/743)

View File

@@ -142,12 +142,16 @@ class TwigExtension extends \Twig_Extension
public function safeEmailFilter($str)
{
$email = '';
$str_len = strlen($str);
for ($i = 0; $i < $str_len; $i++) {
$email .= "&#" . ord($str[$i]) . ";";
for ( $i = 0, $len = strlen( $str ); $i < $len; $i++ ) {
$j = rand( 0, 1);
if ( $j == 0 ) {
$email .= '&#' . ord( $str[$i] ) . ';';
} elseif ( $j == 1 ) {
$email .= $str[$i];
}
}
return $email;
return str_replace( '@', '&#64;', $email );
}
/**