Moodle
  1. Moodle
  2. MDL-30008

accepted_types ignored by filemanager element

    Details

    • Testing Instructions:
      Hide

      1. Create a new file resource, upload files to it and make sure that it works
      2. Create a database resource with a picture field
      3. Make sure you cannot add something else than a picture
      4. Go to your privates files and upload a bunch of different files, make sure it works
      5. Hack the code of users/filesedit.php and change accepted_types to

      • '.jpg'
      • array('.jpg')
      • array('image')

      6. For the two first ones, make sure the only file uploadable is a jpg
      7. For the array('image') make sure you can only upload standard image files

      Show
      1. Create a new file resource, upload files to it and make sure that it works 2. Create a database resource with a picture field 3. Make sure you cannot add something else than a picture 4. Go to your privates files and upload a bunch of different files, make sure it works 5. Hack the code of users/filesedit.php and change accepted_types to '.jpg' array('.jpg') array('image') 6. For the two first ones, make sure the only file uploadable is a jpg 7. For the array('image') make sure you can only upload standard image files
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_21_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:
    • Rank:
      19552

      Description

      The filemanager form element does not pass the accepted_types option on to the filepicker pop-up.

      Fix:
      In lib/form/filemanager.js, function initializer:

      Find the section with all the 'this.filepicker_options.XXX = ' and add, at the end, the following line:
      this.filepicker_options.accepted_types = options.accepted_types;

      (Original test instructions follows)

      Create a filemanager element and set the 'accepted_types' to, for example, array('*.jpg')
      (e.g. in 'mod/form/post_form.php', line 88 - change "'accepted_types'=>''," to "accepted_types'=>array('.jpg'),")
      Click 'Add'
      Click 'Upload a file'
      Choose any file on your local computer that is NOT a jpeg
      Click 'Upload this file'

      Expected:
      Error message: XX filetype cannot be accepted

      Actual:
      File is accepted without complaint

        Issue Links

          Activity

          Davo Smith created issue -
          Davo Smith made changes -
          Field Original Value New Value
          Labels patch
          Marina Glancy made changes -
          Assignee moodle.com [ moodle.com ] Marina Glancy [ marina ]
          Frédéric Massart made changes -
          Assignee Marina Glancy [ marina ] Frédéric Massart [ fred ]
          Frédéric Massart made changes -
          Status Open [ 1 ] Development in progress [ 3 ]
          Frédéric Massart made changes -
          Testing Instructions Create a filemanager element and set the 'accepted_types' to, for example, array('*.jpg')
          (e.g. in 'mod/form/post_form.php', line 88 - change "'accepted_types'=>'*'," to "accepted_types'=>array('*.jpg'),")
          Click 'Add'
          Click 'Upload a file'
          Choose any file on your local computer that is NOT a jpeg
          Click 'Upload this file'

          Expected:
          Error message: XX filetype cannot be accepted

          Actual:
          File is accepted without complaint
          1. Create a new file resource, upload files to it and make sure that it works
          2. Create a database resource with a picture field
          3. Make sure you cannot add something else than a picture
          4. Go to your privates files and upload a bunch of different files, make sure it works
          5. Hack the code of users/filesedit.php and change accepted_types to

          - '.jpg'
          - array('.jpg')
          - array('image')

          6. For the two first ones, make sure the only file uploadable is a jpg
          7. For the array('image') make sure you can only upload standard image files
          Description The filemanager form element does not pass the accepted_types option on to the filepicker pop-up.

          Fix:
          In lib/form/filemanager.js, function initializer:

          Find the section with all the 'this.filepicker_options.XXX = ' and add, at the end, the following line:
          this.filepicker_options.accepted_types = options.accepted_types;
          The filemanager form element does not pass the accepted_types option on to the filepicker pop-up.

          Fix:
          In lib/form/filemanager.js, function initializer:

          Find the section with all the 'this.filepicker_options.XXX = ' and add, at the end, the following line:
          this.filepicker_options.accepted_types = options.accepted_types;

          (Original test instructions follows)

          Create a filemanager element and set the 'accepted_types' to, for example, array('*.jpg')
          (e.g. in 'mod/form/post_form.php', line 88 - change "'accepted_types'=>'*'," to "accepted_types'=>array('*.jpg'),")
          Click 'Add'
          Click 'Upload a file'
          Choose any file on your local computer that is NOT a jpeg
          Click 'Upload this file'

          Expected:
          Error message: XX filetype cannot be accepted

          Actual:
          File is accepted without complaint
          Pull 2.2 Diff URL https://github.com/FMCorz/moodle/compare/MOODLE_22_STABLE...MDL-30008-22
          Pull 2.1 Branch MDL-30008-21
          Pull 2.2 Branch MDL-30008-22
          Pull 2.1 Diff URL https://github.com/FMCorz/moodle/compare/MOODLE_21_STABLE...MDL-30008-21
          Pull from Repository git://github.com/FMCorz/moodle.git
          Frédéric Massart made changes -
          Status Development in progress [ 3 ] Waiting for peer review [ 10012 ]
          Andrew Davis made changes -
          Original Estimate 0 minutes [ 0 ]
          Remaining Estimate 0 minutes [ 0 ]
          Status Waiting for peer review [ 10012 ] Peer review in progress [ 10013 ]
          Peer reviewer andyjdavis
          Andrew Davis made changes -
          Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
          Frédéric Massart made changes -
          Status Development in progress [ 3 ] Waiting for integration review [ 10010 ]
          Dan Poltawski made changes -
          Currently in integration Yes [ 10041 ]
          Dan Poltawski made changes -
          Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
          Integrator poltawski
          Dan Poltawski made changes -
          Status Integration review in progress [ 10004 ] Waiting for testing [ 10005 ]
          Fix Version/s 2.1.7 [ 12161 ]
          Fix Version/s 2.2.4 [ 12162 ]
          Rajesh Taneja made changes -
          Status Waiting for testing [ 10005 ] Testing in progress [ 10011 ]
          Tester rajeshtaneja
          Rajesh Taneja made changes -
          Status Testing in progress [ 10011 ] Tested [ 10006 ]
          Sam Hemelryk made changes -
          Status Tested [ 10006 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          Currently in integration Yes [ 10041 ]
          Integration date 06/Jul/12
          Frédéric Massart made changes -
          Link This issue caused a regression MDL-34507 [ MDL-34507 ]

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: