Permalink
Browse files

MDL-29712 REST-XML server was translating too many HTML characters. u…

…se htmlspecialchars instead of htmlentities. Translated characters by htmlspecialchars are compatible with XML validation, and so XML parsers for javascript, java...
  • Loading branch information...
1 parent 17e0ed7 commit 2af51a1dc3b62bcb16d59d53a8d156766af79494 @mouneyrac mouneyrac committed with Sam Hemelryk Dec 2, 2011
Showing with 3 additions and 3 deletions.
  1. +3 −3 webservice/rest/locallib.php
@@ -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";
}
@@ -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) {

0 comments on commit 2af51a1

Please sign in to comment.