Skip to content

Commit

Permalink
MDL-29712 REST-XML server was translating too many HTML characters. u…
Browse files Browse the repository at this point in the history
…se htmlspecialchars instead of htmlentities. Translated characters by htmlspecialchars are compatible with XML validation, and so XML parsers for javascript, java...
  • Loading branch information
mouneyrac authored and Sam Hemelryk committed Dec 7, 2011
1 parent 17e0ed7 commit 2af51a1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions webservice/rest/locallib.php
Expand Up @@ -138,9 +138,9 @@ protected function generate_error($ex) {
} else {
$error = '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
$error .= '<EXCEPTION class="'.get_class($ex).'">'."\n";
$error .= '<MESSAGE>'.htmlentities($ex->getMessage(), ENT_COMPAT, 'UTF-8').'</MESSAGE>'."\n";
$error .= '<MESSAGE>'.htmlspecialchars($ex->getMessage(), ENT_COMPAT, 'UTF-8').'</MESSAGE>'."\n";
if (debugging() and isset($ex->debuginfo)) {
$error .= '<DEBUGINFO>'.htmlentities($ex->debuginfo, ENT_COMPAT, 'UTF-8').'</DEBUGINFO>'."\n";
$error .= '<DEBUGINFO>'.htmlspecialchars($ex->debuginfo, ENT_COMPAT, 'UTF-8').'</DEBUGINFO>'."\n";
}
$error .= '</EXCEPTION>'."\n";
}
Expand Down Expand Up @@ -182,7 +182,7 @@ protected static function xmlize_result($returns, $desc) {
if (is_null($returns)) {
return '<VALUE null="null"/>'."\n";
} else {
return '<VALUE>'.htmlentities($returns, ENT_COMPAT, 'UTF-8').'</VALUE>'."\n";
return '<VALUE>'.htmlspecialchars($returns, ENT_COMPAT, 'UTF-8').'</VALUE>'."\n";
}

} else if ($desc instanceof external_multiple_structure) {
Expand Down

0 comments on commit 2af51a1

Please sign in to comment.