From ad81861c331f60ec8c19ea11e47e2826660fa142 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 31 May 2009 00:11:02 -0700 Subject: First pass at an XSS security test, along with the "p" helper which can clean HTML output. --- modules/gallery/helpers/p.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 modules/gallery/helpers/p.php (limited to 'modules/gallery/helpers/p.php') diff --git a/modules/gallery/helpers/p.php b/modules/gallery/helpers/p.php new file mode 100644 index 00000000..69032840 --- /dev/null +++ b/modules/gallery/helpers/p.php @@ -0,0 +1,33 @@ +purify($dirty_html)); + } + + function clean($dirty_html) { + // return $dirty_html; + return htmlentities($dirty_html, ENT_QUOTES); + // return Purify::instance()->purify($dirty_html); + } +} -- cgit v1.2.3 From f9a741782da848c707ac0a122c35e86061a0fbb2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 31 May 2009 12:33:10 -0700 Subject: Switch to using html::specialchars() for cleaning. --- modules/gallery/helpers/p.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'modules/gallery/helpers/p.php') diff --git a/modules/gallery/helpers/p.php b/modules/gallery/helpers/p.php index 69032840..c3074c23 100644 --- a/modules/gallery/helpers/p.php +++ b/modules/gallery/helpers/p.php @@ -18,16 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class p_Core { - static function attr($dirty_html) { - // return $dirty_html; - return htmlentities($dirty_html, ENT_QUOTES); - // return str_replace('"', '"', $dirty_html); - // return str_replace('"', '"', Purify::instance()->purify($dirty_html)); - } - function clean($dirty_html) { - // return $dirty_html; - return htmlentities($dirty_html, ENT_QUOTES); - // return Purify::instance()->purify($dirty_html); + return html::specialchars($dirty_html); } } -- cgit v1.2.3