From 73d68a033dc3365f069be19bd14874491c654e2e Mon Sep 17 00:00:00 2001 From: stronk7 Date: Fri, 2 Sep 2005 00:01:22 +0000 Subject: [PATCH] Strip control chars from being sent to the XML file. Only tab, newline and return are allowed in XML 1.0. This feature is controlled by $CFG->backup_strip_controlchars. Please, test it! --- backup/backuplib.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backup/backuplib.php b/backup/backuplib.php index 62fccd482b8..d188c45a8d2 100644 --- a/backup/backuplib.php +++ b/backup/backuplib.php @@ -435,8 +435,20 @@ //Return the start tag, the contents and the end tag function full_tag($tag,$level=0,$endline=true,$content,$to_utf=true) { + + global $CFG; + //Here we encode absolute links $content = backup_encode_absolute_links($content); + + //If enabled, we strip all the control chars from the text but tabs, newlines and returns + //because they are forbiden in XML 1.0 specs. The expression below seems to be + //UTF-8 safe too because it simply ignores the rest of characters. + if (!empty($CFG->backup_strip_controlchars)) { + $content = preg_replace("/(?(?=[[:cntrl:]])[^\n\r\t])/is","",$content); + } + + //Start to build the tag $st = start_tag($tag,$level,$endline); $co=""; if ($to_utf) {