From c1ccd41248939464f659534dc18201039f4fe1d6 Mon Sep 17 00:00:00 2001 From: andrew Date: Fri, 27 Feb 2004 13:45:19 +0000 Subject: [PATCH] Type: Functionality change Description: Includes XSS attack prevention. Behaviour before fix: XSS attack could be performed on login.php. Behaviour after fix: XSS attacks seem unsuccessful after patch. Credit: Thanks to Jonathan E. Hawkins for pointing out this bug. --- lib/sanitize.inc | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+), 0 deletions(-) create mode 100644 lib/sanitize.inc diff --git a/lib/sanitize.inc b/lib/sanitize.inc new file mode 100644 index 0000000..e02beac --- /dev/null +++ b/lib/sanitize.inc @@ -0,0 +1,40 @@ +, Jam Warehouse (Pty) Ltd, South Africa + */ + +/** + * Accepts a web encoded string and outputs a "clean" string. + */ + +function sanitize($string) { + // Remove '(' and ')' + $xss_array = array("(" => "#&40;", ")" => "#&41;"); + // Remove all HTML tags. + $string = strtr(strip_tags(urldecode($string)), $xss_array); + return $string; +} + +?> -- libgit2 0.21.4