Uploaded image for project: '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:

      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

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              davosmith Davo Smith created issue -
              davosmith Davo Smith made changes -
              Field Original Value New Value
              Labels patch
              marina Marina Glancy made changes -
              Assignee moodle.com [ moodle.com ] Marina Glancy [ marina ]
              fred Frédéric Massart made changes -
              Assignee Marina Glancy [ marina ] Frédéric Massart [ fred ]
              fred Frédéric Massart made changes -
              Status Open [ 1 ] Development in progress [ 3 ]
              fred 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
              fred Frédéric Massart made changes -
              Status Development in progress [ 3 ] Waiting for peer review [ 10012 ]
              andyjdavis 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
              andyjdavis Andrew Davis made changes -
              Status Peer review in progress [ 10013 ] Development in progress [ 3 ]
              fred Frédéric Massart made changes -
              Status Development in progress [ 3 ] Waiting for integration review [ 10010 ]
              poltawski Dan Poltawski made changes -
              Currently in integration Yes [ 10041 ]
              poltawski Dan Poltawski made changes -
              Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
              Integrator poltawski
              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 ]
              rajeshtaneja Rajesh Taneja made changes -
              Status Waiting for testing [ 10005 ] Testing in progress [ 10011 ]
              Tester rajeshtaneja
              rajeshtaneja Rajesh Taneja made changes -
              Status Testing in progress [ 10011 ] Tested [ 10006 ]
              samhemelryk Sam Hemelryk made changes -
              Status Tested [ 10006 ] Closed [ 6 ]
              Resolution Fixed [ 1 ]
              Currently in integration Yes [ 10041 ]
              Integration date 06/Jul/12
              fred 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:
                    Fix Release Date:
                    9/Jul/12