Author rodrigo.parra
Recipients rodrigo.parra, tim.golden
Date 2014-01-25.17:17:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1390670268.05.0.579524422182.issue20392@psf.upfronthosting.co.za>
In-reply-to
Content
The functions looks up for the file extension in three maps: types_map, suffix_map and encodings_map.

Lookup in types_map is case insensitive (by calling lower() first).
Lookup in both suffix_map and encodings_map is case sensitive.

These can lead to some seemingly counterintuitive results, like:

a)
guess_type("foo.tar") == ("application/x-tar", None)
guess_type("foo.TAR") == ("application/x-tar", None)

b)
guess_type("foo.tgz") == ("application/x-tar", "gzip")
guess_type("foo.TGZ") == (None, None)

c)
guess_type("foo.tar.gz") == ("application/x-tar", "gzip")
guess_type("foo.TAR.GZ") == (None, None)

Lookup should be case insensitive at least for the suffix_map, in which case (b) would be solved. The submitted patch implements this change.

As for the encodings_map, I am not so sure, in particular because of the tar.Z extension. I found that the compress command expects the uppercase 'Z'. If someone is relying in the results of guess_type to call compress, errors could occur.
History
Date User Action Args
2014-01-25 17:17:48rodrigo.parrasetrecipients: + rodrigo.parra, tim.golden
2014-01-25 17:17:48rodrigo.parrasetmessageid: <1390670268.05.0.579524422182.issue20392@psf.upfronthosting.co.za>
2014-01-25 17:17:47rodrigo.parralinkissue20392 messages
2014-01-25 17:17:47rodrigo.parracreate