diff --git a/src/Pluf/Template.php b/src/Pluf/Template.php index 08d3334..889f674 100644 --- a/src/Pluf/Template.php +++ b/src/Pluf/Template.php @@ -285,4 +285,14 @@ function Pluf_Template_timeAgo($date, $f="withal") } else { return Pluf_Date_Easy($date, null, 2, __('now'), false); } +} + +/** + * Hex encode an email excluding the "mailto:". + */ +function Pluf_Template_safeEmail($email) +{ + $email = chunk_split(bin2hex($email), 2, '%'); + $email = '%'.substr($email, 0, strlen($email) - 1); + return Pluf_Template::markSafe($email); } \ No newline at end of file diff --git a/src/Pluf/Template/Compiler.php b/src/Pluf/Template/Compiler.php index 54df8d7..8bae0e7 100644 --- a/src/Pluf/Template/Compiler.php +++ b/src/Pluf/Template/Compiler.php @@ -107,6 +107,7 @@ class Pluf_Template_Compiler 'time' => 'Pluf_Template_timeFormat', 'dateago' => 'Pluf_Template_dateAgo', 'timeago' => 'Pluf_Template_timeAgo', + 'email' => 'Pluf_Template_safeEmail', ); /**