]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16570
authorthepurpleblob <thepurpleblob>
Fri, 19 Sep 2008 10:01:47 +0000 (10:01 +0000)
committerthepurpleblob <thepurpleblob>
Fri, 19 Sep 2008 10:01:47 +0000 (10:01 +0000)
Use CDATA sections for text where required. More readable and less error
prone.

Merged from MOODLE_19_STABLE

question/format/xml/format.php

index df5a6aaf6a95f2232a052c1cc9490674f70572c8..8f8edad9cf9e0d1dac12f1daa6ba06210709325a 100755 (executable)
@@ -692,8 +692,10 @@ class qformat_xml extends qformat_default {
     function writetext( $raw, $ilev=0, $short=true) {
         $indent = str_repeat( "  ",$ilev );
 
-        // encode the text to 'disguise' HTML content 
-        $raw = htmlspecialchars( $raw );
+        // if required add CDATA tags
+        if (!empty($raw) and (htmlspecialchars($raw)!=$raw)) {
+            $raw = "<![CDATA[$raw]]>";
+        }
 
         if ($short) {
             $xml = "$indent<text>$raw</text>\n";