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

user_get_grade_items WS throws exception with special characters and spaces

XMLWordPrintable

      We found that in certain courses, the gradereport_user_get_grade_items webservice function would return

      {"exception":"invalid_response_exception","errorcode":"invalidresponse","message":"Invalid response value detected"}

      It turns out that this was because the affected courses had one or more grade items that included an ampersand (&) in the name of a grade item. This causes an issue because the validation structure in /grade/report/user/classes/external/user.php defines the itemname as PARAM_CLEANHTML; meanwhile, it appears that when a parameter of this type is cleaned in the validate_param function in lib/moodlelib.php, the ampersand symbol is converted from

      "&"

      to

      "&" 

      This is problematic because validate_param does a check that fails if the cleaned string does not match the original string on line 791 of lib/moodlelib.php, and it is here that the error is ultimately thrown that appears in the response.

      Note that the parameter type CLEANHTML was changed recently from TEXT; the latter type did not cause this issue. The tracker item that resulted in that change is here: https://tracker.moodle.org/browse/MDL-78533

      It seems there are two possible solutions to this issue:

      • Change the parameter type for itemname again to something else that fulfills the requirements for both tickets
      • Alter the conditional in validate_param to account for this case
        • This seems to be the better option to me – I'm surprised that this issue hasn't appeared elsewhere.

      (Feel free to close if this issue should be handled elsewhere, like on the original ticket)

            jleyva Juan Leyva
            bryce.yoder@moodle.com Bryce Yoder
            Dani Palou Dani Palou
            Huong Nguyen Huong Nguyen
            CiBoT CiBoT
            Votes:
            23 Vote for this issue
            Watchers:
            46 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 35 minutes
                3h 35m

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