Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-28461

Web service 2.0 why error messages in REST mode are passed to htmlentities before sending to client ?

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Trivial Trivial
    • None
    • 2.1
    • Web Services
    • Any
    • MOODLE_21_STABLE
    • Hide

      see above

      Show
      see above

      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 .= '<DEBUGINFO>'.htmlentities($ex->debuginfo, ENT_COMPAT, 'UTF-8').'</DEBUGINFO>'."\n"; }

      $xml .= '</EXCEPTION>'."\n";
      echo $xml;
      }

      Cheers

        1. screenshot_002.png
          31 kB
          Patrick Pollet
        2. screenshot_003.png
          35 kB
          Patrick Pollet
        3. screenshot_004.png
          25 kB
          Patrick Pollet

            Unassigned Unassigned
            ppollet Patrick Pollet (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.