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

Incorrectly formatted returned values in mod URL, prevents course_get_contents WS to work

    XMLWordPrintable

Details

    • MOODLE_27_STABLE
    • MOODLE_26_STABLE, MOODLE_27_STABLE
    • MDL-47690-master
    • Hide
      1. Inside a course create a couple of resources (type URL), the Name of the resource should contain characters like ": & . ../ ./ & < >" etc..
      2. Enable "Mobile services": Plugins ► Web Services ► External services
      3. Create a Token:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      4. Click add, select user and service (Mobile Service)
      5. Next, you can do a CURL REST call simulating a WS client:
        • You need to replace the courseid values .
        • You also need to replace the wstoken and the URL of your moodle instance

          curl 'http://localhost/moodlebugs/webservice/rest/server.php?moodlewsrestformat=json' -H 'Pragma: no-cache' -H 'Origin: file://' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Cookie: MoodleSession=f40pv08phpbc79boa0oh8h2r94' -H 'Connection: keep-alive' --data 'options%5B0%5D%5Bname%5D=&options%5B0%5D%5Bvalue%5D=&courseid=4&wsfunction=core_course_get_contents&wstoken=493d2e785f81515296cf09e05f1f8179' --compressed
          

      6. Confirm that:
        • The result of that curl call list all contents and resources in the course, the filename attirubte of the URLs is correctly formatted, all the invalid characterse like : has ben removed, you can use http://jsonlint.com to format the output
      Show
      Inside a course create a couple of resources (type URL), the Name of the resource should contain characters like ": & . ../ ./ & < >" etc.. Enable "Mobile services": Plugins ► Web Services ► External services Create a Token: Click on Site administration ► Plugins ► Web services ► Manage tokens Click add, select user and service (Mobile Service) Next, you can do a CURL REST call simulating a WS client: You need to replace the courseid values . You also need to replace the wstoken and the URL of your moodle instance curl 'http://localhost/moodlebugs/webservice/rest/server.php?moodlewsrestformat=json' -H 'Pragma: no-cache' -H 'Origin: file://' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Accept-Language: es,en;q=0.8,de-DE;q=0.6,de;q=0.4' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1798.0 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Cookie: MoodleSession=f40pv08phpbc79boa0oh8h2r94' -H 'Connection: keep-alive' --data 'options%5B0%5D%5Bname%5D=&options%5B0%5D%5Bvalue%5D=&courseid=4&wsfunction=core_course_get_contents&wstoken=493d2e785f81515296cf09e05f1f8179' --compressed Confirm that: The result of that curl call list all contents and resources in the course, the filename attirubte of the URLs is correctly formatted, all the invalid characterse like : has ben removed, you can use http://jsonlint.com to format the output

    Description

      The filename parameter should be declared as PARAM_TEXT since some types of resources (like URL) uses the "filename" attribute to store the resource name.

      We choose to use PARAM_TEXT since resource name may have multilingual tags

      Note that finally we have fixed at mod URL module cleaning the parameter returned to be correctly PARAM_FILE

      Attachments

        Issue Links

          Activity

            People

              jleyva Juan Leyva
              jleyva Juan Leyva
              Ankit Agarwal Ankit Agarwal
              Damyon Wiese Damyon Wiese
              Zachary Durber Zachary Durber
              Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie, Juan Leyva, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              2 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                10/Nov/14