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 committed Dec 2, 2011
1 parent a5b5881 commit d2f127e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions webservice/rest/locallib.php
Original file line number Diff line number Diff line change
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 d2f127e

Please sign in to comment.