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

LTI broken for courses with long activity name, course name or site name

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 3.2.3
    • Fix Version/s: None
    • Labels:
      None
    • Testing Instructions:
      Hide
      1. Create/edit a course giving it a name (fullname or shortname) with more than 75 characters (including at least one whitespace).
      2. In this course, create an external (LTI) link to https://lti.tools/test/tp.php with any key and secret.
      3. Launch the tool and notice it gives an "Could not validate request: OAuth signature check failed" error.
      Show
      Create/edit a course giving it a name (fullname or shortname) with more than 75 characters (including at least one whitespace). In this course, create an external (LTI) link to https://lti.tools/test/tp.php with any key and secret. Launch the tool and notice it gives an "Could not validate request: OAuth signature check failed" error.
    • Workaround:
      Hide

      Use fullname, shortname and instance name with less than 75 characters.

      Show
      Use fullname, shortname and instance name with less than 75 characters.
    • Affected Branches:
      MOODLE_32_STABLE

      Description

      The External Tool (LTI) module breaks if a course's shortname or fullname contains more than 75 characters.
      We have noticed this behaviour in several courses after the update from Moodle 3.1 to 3.2.

      MDL-58770 introduced HTML stripping in function lti_build_request() in mod/lti/locallib.php through the function html_to_text() in lib/weblib.php
      https://git.moodle.org/gw?p=moodle.git;a=commit;h=1768b85f09e45caa954d21022ffaf4f82c4dc5d3

      'context_label' => trim(html_to_text($course->shortname)),
      'context_title' => trim(html_to_text($course->fullname)),

      html_to_text() by default wraps the text at 75 characters, which shows as %0D%0A in LTI POST's context_label or context_title. This seems to break LTI functionality.

       

      As a temporary fix, adding ", 0, false" to the function arguments makes LTI behave correctly again.

      'context_label' => trim(html_to_text($course->shortname, 0, false)),
      'context_title' => trim(html_to_text($course->fullname, 0, false)),

      The same changes should probably be applied to resource_link_title as well...

      $requestparams['resource_link_title'] = trim(html_to_text($instance->name, 0, false));

      ... and to tool_consumer_instance_name and tool_consumer_instance_description in function lti_build_standard_request().

      if (!empty($CFG->mod_lti_institution_name)) {
          $requestparams['tool_consumer_instance_name'] = trim(html_to_text($CFG->mod_lti_institution_name, 0, false));
      } else {
          $requestparams['tool_consumer_instance_name'] = trim(html_to_text(get_site()->shortname, 0, false));
      }
      $requestparams['tool_consumer_instance_description'] = trim(html_to_text(get_site()->fullname, 0, false));

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              schach Heiko Schach
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
              Votes:
              4 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: