From: martin <martin>
Date: Tue, 26 Mar 2002 12:58:54 +0000 (+0000)
Subject: Added cleantext function, used for cleaning user-entered text of nasty tags etc
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=b7a3cf49f8175dc51b745c9891092f99baab9643;p=moodle.git

Added cleantext function, used for cleaning user-entered text of nasty tags etc
---

diff --git a/lib/weblib.php b/lib/weblib.php
index 10e1d7ce3e..56590eb25b 100644
--- a/lib/weblib.php
+++ b/lib/weblib.php
@@ -256,11 +256,19 @@ function get_slash_arguments($i=0) {
 }
 
 
-function text_to_html($text) {
-    global $CFG;
+function cleantext($text) {
+// Given raw text (eg typed in by a user), this function cleans it up 
+// and removes any nasty tags that could mess up Moodle pages.
+
+    return strip_tags($text, '<b><i><u><font>');
+}
 
+
+function text_to_html($text) {
 // Given plain text, makes it into HTML as nicely as possible.
 
+    global $CFG;
+
     // Make URLs into links.   eg http://moodle.com/
     $text = eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])", 
                           "<A HREF=\"\\1://\\2\\3\" TARGET=\"newpage\">\\1://\\2\\3</A>", $text);