MDL-29712server was translating too many HTML characters. use htmlspecialchars instead of htmlentities. Translated characters by htmlspecialchars are compatible with XML validation, and so XML parsers for javascript, java...

This commit is contained in:
Jerome Mouneyrac
2011-12-05 14:17:26 +08:00
parent 28ab88e130
commit dd154420ee
+3 -3
View File
@@ -95,9 +95,9 @@ class webservice_rest_server extends webservice_base_server {
$this->send_headers();
$xml = '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
$xml .= '<EXCEPTION class="'.get_class($ex).'">'."\n";
$xml .= '<MESSAGE>'.htmlentities($ex->getMessage(), ENT_COMPAT, 'UTF-8').'</MESSAGE>'."\n";
$xml .= '<MESSAGE>'.htmlspecialchars($ex->getMessage(), ENT_COMPAT, 'UTF-8').'</MESSAGE>'."\n";
if (debugging() and isset($ex->debuginfo)) {
$xml .= '<DEBUGINFO>'.htmlentities($ex->debuginfo, ENT_COMPAT, 'UTF-8').'</DEBUGINFO>'."\n";
$xml .= '<DEBUGINFO>'.htmlspecialchars($ex->debuginfo, ENT_COMPAT, 'UTF-8').'</DEBUGINFO>'."\n";
}
$xml .= '</EXCEPTION>'."\n";
echo $xml;
@@ -134,7 +134,7 @@ class webservice_rest_server extends webservice_base_server {
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) {