Skip to content

Commit

Permalink
question import/export MDL-23198 extra_question_fields not handling s…
Browse files Browse the repository at this point in the history
…pecial characters properly.

Thanks to Oleg Sychev for the fix.
  • Loading branch information
timhunt committed Aug 11, 2010
1 parent 874a2ea commit a1a0d9a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions question/type/questiontype.php
Expand Up @@ -1732,7 +1732,7 @@ function import_from_xml($data, $question, $format, $extra=null) {
$qo->qtype = $question_type;

foreach ($extraquestionfields as $field) {
$qo->$field = $format->getpath($data, array('#',$field,0,'#'), $qo->$field);
$qo->$field = addslashes($format->getpath($data, array('#',$field,0,'#'), $qo->$field));
}

// run through the answers
Expand Down Expand Up @@ -1769,7 +1769,11 @@ function export_to_xml($question, $format, $extra=null) {
array_shift($extraquestionfields);
$expout='';
foreach ($extraquestionfields as $field) {
$expout .= " <$field>{$question->options->$field}</$field>\n";
$exportedvalue = $question->options->$field;
if (!empty($exportedvalue) && htmlspecialchars($exportedvalue) != $exportedvalue) {
$exportedvalue = '<![CDATA[' . $exportedvalue . ']]>';
}
$expout .= " <$field>{$exportedvalue}</$field>\n";
}

$extraasnwersfields = $this->extra_answer_fields();
Expand Down

0 comments on commit a1a0d9a

Please sign in to comment.