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

mod/resource does not handle video files with names containing '#' correctly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.4.6, 3.6
    • Fix Version/s: 3.5.5, 3.6.3
    • Component/s: Resource
    • Labels:
    • Testing Instructions:
      Hide
      1. Navigate to a course.
      2. Turn editing on.
      3. Click any 'Add an activity or resource' link
      4. Under 'Resources', select 'File', click 'Add'.
      5. Give the resource an arbitrary name.
      6. Under 'Select files', upload a video file, named "File #1.mp4".
      7. Save and display.
      8. Check That the video is displayed properly and there is no error.
      9. Repeat the steps above, but with different file types (at least an image, and a pdf).
      10. Check That each of the file types still works and that there are no errors.
      Show
      Navigate to a course. Turn editing on. Click any 'Add an activity or resource' link Under 'Resources', select 'File', click 'Add'. Give the resource an arbitrary name. Under 'Select files', upload a video file, named "File #1.mp4". Save and display. Check That the video is displayed properly and there is no error. Repeat the steps above, but with different file types (at least an image, and a pdf). Check That each of the file types still works and that there are no errors.
    • Affected Branches:
      MOODLE_34_STABLE, MOODLE_36_STABLE
    • Fixed Branches:
      MOODLE_35_STABLE, MOODLE_36_STABLE
    • Pull from Repository:
    • Pull 3.5 Branch:
    • Pull 3.6 Branch:
    • Pull Master Branch:
      MDL-64346-master

      Description

      STEPS TO REPRODUCE:

      1. Navigate to a course.
      2. Turn editing on.
      3. Click any 'Add an activity or resource' link
      4. Under 'Resources', select 'File', click 'Add'.
      5. Give the resource an arbitrary name.
      6. Under 'Select files', upload a video file, named "File #1.mp4".
      7. Save and display.

      EXPECTED:

      The video appears embedded within the page.

      ACTUAL:

      The page displays an iframe with a message that the file could not be found.

      WORKAROUND:

      Renaming the file to remove the # resolves the issue.

       

      It appears that the pluginfile URL is being interpreted as containing an anchor in function resource_display_embed().

      mod/resource/locallib.php:69-71 (v3.4.6)

          $path = '/'.$context->id.'/mod_resource/content/'.$resource->revision.$file->get_filepath().$file->get_filename();
          $fullurl = file_encode_url($CFG->wwwroot.'/pluginfile.php', $path, false);
          $moodleurl = new moodle_url('/pluginfile.php' . $path);
      

      $fullurl is percent-encoded, whereas $path is not. Replacing the last line with

          $moodleurl = new moodle_url($fullurl);
      

      could be a possible fix.  Would this have unintended consequences?

      Might be good to fix this while deprecating file_encode_url(), per https://tracker.moodle.org/browse/MDL-31071

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/Mar/19

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 17 minutes
                17m