-
Bug
-
Resolution: Won't Do
-
Trivial
-
None
-
2.1
-
Any
-
MOODLE_21_STABLE
-
Hello,
While testing 2.0 Web Service, and more specifically integration of oktech operations under 2.0 infrastructure I noticed that error messages in REST protocol were returned to client after conversion to html entities. This has two unpleaseant side effects :
1) when testing Web service under Site Administration, Development, Web service Test Client , output in case or error is messed by some HTML tags such as eacute; ocirc; ... see attached screenshot 1
2) more annoying, when testing Web service with a browser such as Chrome by calling something like http://localhost/moodle.git/webservice/rest/server.php?wsfunction=oktech_get_users&wstoken=wrongtoken the returned error message cannot be parsed by Chrome due to unexpected entities. One has to selected 'see page source code' to discover the real error message . See attached screenshots
I did fix it in by removing calls to htmlentities in function send_error in webservice/rest/locallib.php
protected function send_error($ex=null) {
$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";
if (debugging() and isset($ex->debuginfo))
$xml .= '</EXCEPTION>'."\n";
echo $xml;
}
Cheers
- will be (partly) resolved by
-
MDL-29712 The REST web service creates invalid XML by encoding HTML entities
-
- Closed
-