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

Resource Force download causes unable to open error or Android devices and ios7+ devices

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Instructions

      1. Click on any file resource with force download enabled.

      Expected Results

      1. Except for iOS devices, the file should get downloaded and be saved locally.
      2. If installed and available, the appropriate application associated with the downloaded file should be able to open it.

      Others

      1. Try to download a HTML file with JavaScript. The browser should not automatically open the file and the JS script should not run.
      2. Perform this test on major desktop and mobile (iOS/Android) browsers.
      Show
      Instructions Click on any file resource with force download enabled. Expected Results Except for iOS devices, the file should get downloaded and be saved locally. If installed and available, the appropriate application associated with the downloaded file should be able to open it. Others Try to download a HTML file with JavaScript. The browser should not automatically open the file and the JS script should not run. Perform this test on major desktop and mobile (iOS/Android) browsers.
    • Affected Branches:
      MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_28_STABLE, MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_28_STABLE, MOODLE_29_STABLE
    • Pull Master Branch:
      MDL-44828-master
    • Sprint:
      Team '; drop tables Sprint 9

      Description

      Any resources that have force download enable are unable to be opened directly on an android device.
      For example any pdf, gif or any file type stored in a "folder" resource is set to force download = true
      if you try and download any of these files on an android device with chrome or the AOSP browser it downloads but when trying to open the file from the notification bar or download manager, you get the error "can't open file"
      The file is not actually corrupted as if a file explorer is downloaded and the file is located and opened manually it still works.
      This problem is due to the wrong mime type being sent with the file
      The android download manager relies on the correct mime file type being sent to open the file.
      This has been tested on multiple android devices, nexus 7 (2013) android 4.4 chrome v30 , sony xperia s android 4.1.2 chrome v30 and AOSP browser
      In some other discussions/trackers/ it was mentioned this is intentional for XSS security purposes, but on android none of these file types open in the browser, they all open through download manager only. (tested .pdf, .gif, .html)
      See existing discussions here:
      https://tracker.moodle.org/browse/MDL-43764
      https://tracker.moodle.org/browse/MDL-36917
      also see: https://moodle.org/mod/forum/discuss.php?d=164712

      A patch is provided in MDL-36917 which was abandoned, it patched /lib/filelib.php to enable mime type sending for android devices

      I am proposing a modified version of this patch , However android browser detection also needs patching as it does not correctly detect androids default browser (chrome) after 4.1.2 - i will log this separately, patches to come

        Attachments

        1. badhtml.html
          2 kB
        2. Chrome_open.png
          Chrome_open.png
          81 kB
        3. FF_open.png
          FF_open.png
          132 kB
        4. HelloWorld.swf
          0.9 kB
        5. IE_open.png
          IE_open.png
          61 kB
        6. SWF_on_Android.png
          SWF_on_Android.png
          53 kB

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/Sep/15