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

Unable to download resources of type "File" with name of 90+ bytes

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Enable developer mode

      • Debug messages = "DEVELOPER: extra Moodle debug messages for developers" (Administration > Development > Debbuging)

      Scenario 1:

      1. Log in as Admin.
      2. Create a Course.
      3. Create a File resource.
        • Upload a file with a filename of 128 characters in Moodle 3.1.
        • 'Save and display' the resource.
      1. Open the file resource.
        • make sure the file can be viewed/downloaded.
      2. Upgrade to the latest Moodle release (3.4.x).
      3. Go to the File resource in the Course.
        • make sure the file can be viewed/downloaded and an error is NOT displayed. 

      Scenario 2 (----MDL-60398----):

      1. Log in as Admin
      2. Create a Course.
      3. Create a Folder resource into the Course.
        • add a long name

      ANDREW IS HERE: abcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()-=_+XABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-=_+Xabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()-=_+XABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-=_+

      *

        • Upload at least one file to the Folder.
        • Click "Save and display".
      1. In the Folder resource, click "Download folder".
        • Make sure errors are NOT displayed and the folder is downloading.
        • Make sure the name of the downloaded zip contains an extract of the Folder's name (100 characters).

      Scenario 3 (MDL-61723):

      1. Log in as Admin.
      2. Create a course.
        1. make sure the shortname of the Course is long (more than 120 characters).
      3. Go to the Course.
      4. Click on the action menu and select "Backup".
      5. Click on the "Next" button. (NOT "jump to final step")
      6. Click again on "Next".
        • make sure you can see "Confirmation and review" and an error is NOT displayed (error/setting_invalid_filename)
      7. Perform the backup.
        • make sure the backup is successfully created.
      Show
      Enable developer mode Debug messages = "DEVELOPER: extra Moodle debug messages for developers" (Administration > Development > Debbuging) Scenario 1: Log in as Admin. Create a Course. Create a File resource. Upload a file with a filename of 128 characters in Moodle 3.1. 'Save and display' the resource. Open the file resource. make sure the file can be viewed/downloaded. Upgrade to the latest Moodle release (3.4.x). Go to the File resource in the Course. make sure the file can be viewed/downloaded and an error is NOT displayed.   Scenario 2 (---- MDL-60398 ----): Log in as Admin Create a Course. Create a Folder resource into the Course. add a  long name :  ANDREW IS HERE: abcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()-=_+XABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-=_+Xabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()-=_+XABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()-=_+ * Upload at least one file to the Folder. Click "Save and display". In the Folder resource, click "Download folder". Make sure errors are NOT displayed and the folder is downloading. Make sure the name of the downloaded zip contains an extract of the Folder's name (100 characters). Scenario 3 ( MDL-61723 ): Log in as Admin. Create a course. make sure the shortname of the Course is long (more than 120 characters). Go to the Course. Click on the action menu and select "Backup". Click on the "Next" button. (NOT "jump to final step") Click again on "Next". make sure you can see "Confirmation and review" and an error is NOT displayed (error/setting_invalid_filename) Perform the backup. make sure the backup is successfully created.
    • Workaround:
      Hide

      Increase MAX_FILENAME_SIZE in moodlelib.php to the value of the following SQL expression:

      SELECT LENGTH(filename) AS maxlen FROM `mdl_files` WHERE LENGTH(filename) > 90 ORDER BY maxlen DESC LIMIT 1;
      

       

      Show
      Increase MAX_FILENAME_SIZE in moodlelib.php to the value of the following SQL expression: SELECT LENGTH(filename) AS maxlen FROM `mdl_files` WHERE LENGTH(filename) > 90 ORDER BY maxlen DESC LIMIT 1;  
    • Affected Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE
    • Fixed Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE
    • Pull Master Branch:
      MDL-61724-master

      Description

      MDL-60398 introduced a hard limit (MAX_FILENAME_SIZE, 90 bytes) on the length of file and directory names. What it didn't provide, however, is a migration path for files that were uploaded before the update to 3.4.2/3.2.5.

      Currently, when PATH_INFO passes through clean_param(..., PARAM_PATH/PARAM_FILE) - e.g. when a file resource is accessed via pluginfile.php (meaning: course page, filepicker etc.) - the path becomes truncated. This results in all pre-existing files with filenames beyond the 90 byte limit becoming inaccessible. In our use-case (higher ed. with many scientific resources and lecture notes), this affects thousands of files!

       

       

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                9 Vote for this issue
                Watchers:
                19 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  17/May/18

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 4 hours, 20 minutes
                  4h 20m