Mahara needs to check MIME Type "application/x-zip-compressed" when importing LEAP2a zip file.

Bug #514069 reported by Mitsuhiro Yoshida
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Undecided
Richard Mansfield

Bug Description

If the MIME type of LEAP2a zip file is "application/x-zip-compressed", we can't import the file.
We need to fix admin/users/add.php to check MIME Type "application/x-zip-compressed" when importing LEAP2a zip file as below.

File: admin/users/add.php
Line: 202

[before]
if ($values['leap2afile']['type'] == 'application/zip') {

[after]
if ($values['leap2afile']['type'] == 'application/zip'||$values['leap2afile']['type'] == 'application/x-zip-compressed') {

Changed in mahara:
assignee: nobody → Richard Mansfield (richard-mansfield)
status: New → Fix Committed
milestone: none → 1.2.3
Revision history for this message
Mitsuhiro Yoshida (mits) wrote :

Hi Richard,

Thank you very much.

Mits

Changed in mahara:
status: Fix Committed → Fix Released
Revision history for this message
Shen (shzhang) wrote :

We've upgraded Mahara to 1.2.3 and the issue still exists. The error message reads:

"This file has not been detected to be a zipfile or XML file"

In the add.php file, the related lines are as follows:

------------------------------------------------
$ziptypes = PluginArtefactFile::get_mimetypes_from_description('zip');

if (in_array($values['leap2afile']['type'], $ziptypes)) {
------------------------------------------------

Revision history for this message
Richard Mansfield (richard-mansfield) wrote :

Hi Shen,

get_mimetypes_from_description('zip') is currently returning the following list:

 application/zip
 application/x-zip
 application/zip-compressed
 application/x-zip-compressed

This does the job for me in all my test environments but I think your browser might be uploading the file with a mimetype that's not on that list. Google tells me they can also be 'multipart/x-zip', so I can add that one to the list.

But it'd be a great help if we could find out for sure what your browser says it is. You could do this by temporarily replacing line 234 further down that in that file, changing it from

            $form->set_error('leap2afile', get_string('fileisnotaziporxmlfile', 'admin'));

to

            $form->set_error('leap2afile', 'Mime type: ' . $values['leap2afile']['type']);

and then try uploading the file again.

Revision history for this message
Shen (shzhang) wrote :

Hi Richard,

The message I got after the change is:

Mime type: application/octet-stream

Obviously this is not in the list. Can this type be added to the list or is there any settings I need to do to compromise this?

Thanks,
Shen

Revision history for this message
Richard Mansfield (richard-mansfield) wrote :

Thanks Shen, that's really helpful. It means that your browser couldn't work out the correct type of the file, and we can't rely on the browser to tell us the mimetype. We should be able to use mime_content_type (like in https://bugs.launchpad.net/mahara/+bug/520739) to try to guess the type when the browser won't tell us what it is.

Changed in mahara:
status: Fix Released → In Progress
Revision history for this message
Richard Mansfield (richard-mansfield) wrote :
Changed in mahara:
milestone: 1.2.3 → 1.2.4
status: In Progress → Fix Committed
Revision history for this message
Shen (shzhang) wrote :

I've made the changes according to the fix and the importing process is still failing.

The error message in Firefox is the same. IE took me a little further but I got error message in the end goes:

-----------------------------------
Mahara: Site unavailable
A nonrecoverable error occured. This probably means you have encountered a bug in the system
-----------------------------------

The user was created, but no user information nor portfolios attached to it.

Revision history for this message
Richard Mansfield (richard-mansfield) wrote :

Hi Shen,

So is it Firefox that gave you the 'application/octet-stream' mimetype or was it IE?

When you see that 'Site unavailable: A nonrecoverable error occurred' message, there should be an error message in the apache error log. It sounds like a different bug though, which probably has nothing to do with the mime type at all, so it's probably best to create a new bug report for it.

Richard

Revision history for this message
Shen (shzhang) wrote :

The error message that I got from Firefox was 'Mime type: application/octet-stream' still.

Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.