From 3fe3851d57edb91865702ff7d90c1e1d3f6f2b03 Mon Sep 17 00:00:00 2001 From: moodler Date: Fri, 18 Oct 2002 09:09:19 +0000 Subject: [PATCH] OK, I've rationalised the text formatting now. Basically, both Moodle and HTML text allow the same range of HTML tags (so it doesn't matter is you switch from one to the other). and are now ALLOWED in Moodle text. However, the clean_text function now checks for and removes any embedded javascript triggers to avoid cross-site scripting attacks that way. clean_text() should be called on ANY text that comes in from students. --- lib/weblib.php | 51 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/lib/weblib.php b/lib/weblib.php index 2aac5658a1..7289c456c3 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -57,6 +57,13 @@ $SMILEY_IMAGE[] = "\"|-.\"wwwroot/pix/s $SMILEY_TEXT[] = "}-]"; $SMILEY_IMAGE[] = "\"}-]\"wwwroot/pix/s/evil.gif\">"; +$JAVASCRIPT_TAGS = array("javascript:", "onclick=", "ondblclick=", "onkeydown=", "onkeypress=", "onkeyup=", + "onmouseover=", "onmouseout=", "onmousedown=", "onmouseup=", + "onblur=", "onfocus=", "onload=", "onselect="); + +$ALLOWED_TAGS = "