From fa10e0945ecd45bfe78a2c8fb015a43092b4944b Mon Sep 17 00:00:00 2001 From: plegall Date: Thu, 10 Dec 2015 14:02:22 +0100 Subject: bug #385 update to smarty-3.1.28-dev (from Github) --- include/smarty/libs/plugins/function.mailto.php | 45 +++++++++++++------------ 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'include/smarty/libs/plugins/function.mailto.php') diff --git a/include/smarty/libs/plugins/function.mailto.php b/include/smarty/libs/plugins/function.mailto.php index 55d5c0602..520fb7aa6 100644 --- a/include/smarty/libs/plugins/function.mailto.php +++ b/include/smarty/libs/plugins/function.mailto.php @@ -2,13 +2,12 @@ /** * Smarty plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsFunction */ /** * Smarty {mailto} function plugin - * * Type: function
* Name: mailto
* Date: May 21, 2002 @@ -39,22 +38,24 @@ * {mailto address="me@domain.com" extra='class="mailto"'} * * - * @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto} - * (Smarty online manual) - * @version 1.2 - * @author Monte Ohrt - * @author credits to Jason Sweat (added cc, bcc and subject functionality) - * @param array $params parameters - * @param Smarty_Internal_Template $template template object + * @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto} + * (Smarty online manual) + * @version 1.2 + * @author Monte Ohrt + * @author credits to Jason Sweat (added cc, bcc and subject functionality) + * + * @param array $params parameters + * * @return string */ -function smarty_function_mailto($params, $template) +function smarty_function_mailto($params) { static $_allowed_encoding = array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true); $extra = ''; if (empty($params['address'])) { - trigger_error("mailto: missing 'address' parameter",E_USER_WARNING); + trigger_error("mailto: missing 'address' parameter", E_USER_WARNING); + return; } else { $address = $params['address']; @@ -71,8 +72,9 @@ function smarty_function_mailto($params, $template) case 'cc': case 'bcc': case 'followupto': - if (!empty($value)) - $mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value)); + if (!empty($value)) { + $mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value)); + } break; case 'subject': @@ -91,10 +93,11 @@ function smarty_function_mailto($params, $template) if ($mail_parms) { $address .= '?' . join('&', $mail_parms); } - + $encode = (empty($params['encode'])) ? 'none' : $params['encode']; if (!isset($_allowed_encoding[$encode])) { trigger_error("mailto: 'encode' parameter must be none, javascript, javascript_charcode or hex", E_USER_WARNING); + return; } // FIXME: (rodneyrehm) document.write() excues me what? 1998 has passed! @@ -102,7 +105,7 @@ function smarty_function_mailto($params, $template) $string = 'document.write(\'' . $text . '\');'; $js_encode = ''; - for ($x = 0, $_length = strlen($string); $x < $_length; $x++) { + for ($x = 0, $_length = strlen($string); $x < $_length; $x ++) { $js_encode .= '%' . bin2hex($string[$x]); } @@ -110,7 +113,7 @@ function smarty_function_mailto($params, $template) } elseif ($encode == 'javascript_charcode') { $string = '' . $text . ''; - for($x = 0, $y = strlen($string); $x < $y; $x++) { + for ($x = 0, $y = strlen($string); $x < $y; $x ++) { $ord[] = ord($string[$x]); } @@ -125,11 +128,12 @@ function smarty_function_mailto($params, $template) } elseif ($encode == 'hex') { preg_match('!^(.*)(\?.*)$!', $address, $match); if (!empty($match[2])) { - trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.",E_USER_WARNING); + trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.", E_USER_WARNING); + return; } $address_encode = ''; - for ($x = 0, $_length = strlen($address); $x < $_length; $x++) { + for ($x = 0, $_length = strlen($address); $x < $_length; $x ++) { if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[$x])) { $address_encode .= '%' . bin2hex($address[$x]); } else { @@ -137,16 +141,15 @@ function smarty_function_mailto($params, $template) } } $text_encode = ''; - for ($x = 0, $_length = strlen($text); $x < $_length; $x++) { + for ($x = 0, $_length = strlen($text); $x < $_length; $x ++) { $text_encode .= '&#x' . bin2hex($text[$x]) . ';'; } $mailto = "mailto:"; + return '' . $text_encode . ''; } else { // no encoding return '' . $text . ''; } } - -?> \ No newline at end of file -- cgit v1.2.3