MDL-25619 portfolio: exported HTML output can not be cleaned
authorDavid Mudrak <david.mudrak@gmail.com>
Wed, 8 Dec 2010 23:20:04 +0000 (23:20 +0000)
committerDavid Mudrak <david.mudrak@gmail.com>
Wed, 8 Dec 2010 23:20:04 +0000 (23:20 +0000)
lib/portfoliolib.php
mod/assignment/type/online/assignment.class.php
mod/forum/locallib.php
mod/glossary/locallib.php

index 19e00cd..3a90f1b 100644 (file)
@@ -1171,6 +1171,24 @@ function portfolio_existing_exports_by_plugin($userid) {
     return $DB->get_records_sql_menu($sql, $values);
 }
 
+/**
+ * Return default common options for {@link format_text()} when preparing a content to be exported
+ *
+ * It is important not to apply filters and not to clean the HTML in format_text()
+ *
+ * @return stdClass
+ */
+function portfolio_format_text_options() {
+
+    $options                = new stdClass();
+    $options->para          = false;
+    $options->newlines      = true;
+    $options->filter        = false;
+    $options->noclean       = true;
+    $options->overflowdiv   = false;
+
+    return $options;
+}
 
 /**
  * callback function from {@link portfolio_rewrite_pluginfile_urls}
index f4dce79..c153584 100644 (file)
@@ -295,9 +295,7 @@ class assignment_online extends assignment_base {
 
     function portfolio_prepare_package($exporter, $user) {
         $submission = $this->get_submission($user->id);
-        $options = new stdClass();
-        $options->para = false;
-        $options->filter = false;
+        $options = portfolio_format_text_options();
         $html = format_text($submission->data1, $submission->data2, $options);
         $html = portfolio_rewrite_pluginfile_urls($html, $this->context->id, 'mod_assignment', $this->filearea, $submission->id, $exporter->get('format'));
         if (in_array($exporter->get('formatclass'), array(PORTFOLIO_FORMAT_PLAINHTML, PORTFOLIO_FORMAT_RICHHTML))) {
index e790f13..a140380 100644 (file)
@@ -293,9 +293,7 @@ class forum_portfolio_caller extends portfolio_module_caller_base {
         $post->author = $users[$post->userid];
         $viewfullnames = true;
         // format the post body
-        $options = new stdClass();
-        $options->para = false;
-        $options->filter = false;
+        $options = portfolio_format_text_options();
         $format = $this->get('exporter')->get('format');
         $formattedtext = format_text($post->message, $post->messageformat, $options, $this->get('course')->id);
         $formattedtext = portfolio_rewrite_pluginfile_urls($formattedtext, $this->modcontext->id, 'mod_forum', 'post', $post->id, $format);
index 331375e..03727b0 100644 (file)
@@ -375,10 +375,8 @@ class glossary_entry_portfolio_caller extends portfolio_module_caller_base {
         global $OUTPUT, $DB;
         $entry = clone $entry;
         $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-        $options = new stdClass();
-        $options->para = false;
+        $options = portfolio_format_text_options();
         $options->trusted = $entry->definitiontrust;
-        $options->filter = false;
         $options->context = $context;
 
         $output = '<table class="glossarypost dictionary" cellspacing="0">' . "\n";