Merge branch 'MDL-55724-master' of https://github.com/sammarshallou/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 5 Sep 2016 15:33:25 +0000 (17:33 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 5 Sep 2016 15:33:25 +0000 (17:33 +0200)
lib/weblib.php
mod/glossary/import.php

index 391fa9c..3882185 100644 (file)
@@ -1581,6 +1581,10 @@ function strip_pluginfile_content($source) {
  * @return string text without legacy TRUSTTEXT marker
  */
 function trusttext_strip($text) {
+    if (!is_string($text)) {
+        // This avoids the potential for an endless loop below.
+        throw new coding_exception('trusttext_strip parameter must be a string');
+    }
     while (true) { // Removing nested TRUSTTEXT.
         $orig = $text;
         $text = str_replace('#####TRUSTTEXT#####', '', $text);
index 87783e7..f377d07 100644 (file)
@@ -170,7 +170,11 @@ if ($xml = glossary_read_imported_file($result)) {
         $xmlentry = $xmlentries[$i];
         $newentry = new stdClass();
         $newentry->concept = trim($xmlentry['#']['CONCEPT'][0]['#']);
-        $newentry->definition = trusttext_strip($xmlentry['#']['DEFINITION'][0]['#']);
+        $definition = $xmlentry['#']['DEFINITION'][0]['#'];
+        if (!is_string($definition)) {
+            print_error('errorparsingxml', 'glossary');
+        }
+        $newentry->definition = trusttext_strip($definition);
         if ( isset($xmlentry['#']['CASESENSITIVE'][0]['#']) ) {
             $newentry->casesensitive = $xmlentry['#']['CASESENSITIVE'][0]['#'];
         } else {