From a8982662fd90d4fd31a9f5fdc685d7fe782286de Mon Sep 17 00:00:00 2001 From: Conrad Vermeulen Date: Fri, 13 Jul 2007 14:45:12 +0000 Subject: [PATCH] KTS-2178 "cross site scripting" Implemented. --- thirdparty/Smarty/plugins/modifier.sanitize.php | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+), 0 deletions(-) create mode 100644 thirdparty/Smarty/plugins/modifier.sanitize.php diff --git a/thirdparty/Smarty/plugins/modifier.sanitize.php b/thirdparty/Smarty/plugins/modifier.sanitize.php new file mode 100644 index 0000000..99ecaf9 --- /dev/null +++ b/thirdparty/Smarty/plugins/modifier.sanitize.php @@ -0,0 +1,71 @@ +'\\\\',"'"=>"\\'",'"'=>'\\"',"\r"=>'\\r',"\n"=>'\\n',''<\/')); + + case 'mail': + // safe way to display e-mail address on a web page + return str_replace(array('@', '.'),array(' [AT] ', ' [DOT] '), $string); + + case 'nonstd': + // escape non-standard chars, such as ms document quotes + $_res = ''; + for($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) { + $_ord = ord($string{$_i}); + // non-standard char, escape it + if($_ord >= 126){ + $_res .= '&#' . $_ord . ';'; + } + else { + $_res .= $string{$_i}; + } + } + return $_res; + + default: + return $string; + } +} + + +?> -- libgit2 0.21.4