Ticket #7701 (closed Feature Request: duplicate)

Opened 6 years ago

Last modified 4 years ago

Mime type with case insensitive file extensions

Reported by: jcsousa Owned by:
Priority: minor Milestone: 4.0
Component: Archetypes Version:
Keywords: Cc:

Description

When a file have the file extension with uppercase (ex.:xpto.PPT) the detection of Mime type is incorrectly (in that case detect an Word document?!)

Steps to reproduce:
1) Add an Powerpoint file with uppercase extension: xpto.PPT - in windows this is normal :)
2) Confirm that the mime type indicates a Word document instead of an Powerpoint document

Possible solutions:
1) Change in all files the extensions names to lowercase :(
2) In mimetypes_registry add uppercase extensions :(
3) Compare only lowercase extensions :)

jcsousa

Change History

comment:2 Changed 6 years ago by jcsousa

Steps - MimetypesRegistry:

  1. Try to determine mimetype from file extension - MimeTypesRegistry.lookupExtension()
  2. If fail, try to guest from file content - mime_types/magic.py

Quick solution - change in MimeTypesRegistry.lookupExtension():
Remove: return aq_base(self.extensions.get(ext))
Add: return aq_base(self.extensions.get(ext.lower()))
Note: Not work if in ZMI|mimetypes_registry extension only in uppercase or mixed

To improve:

  1. Check only lowercase from both sides
  2. Update magic.py (2003)

jcsousa

comment:3 Changed 6 years ago by hannosch

  • Milestone changed from 3.x to 4.0

I marked #7612 as a duplicate of this ticket.

comment:4 Changed 6 years ago by WouterVH

  • Status changed from new to closed
  • Resolution set to duplicate

Duplicate of #5798.

comment:5 Changed 5 years ago by hannosch

  • Component changed from MimetypesRegistry to Archetypes

comment:6 Changed 4 years ago by hannosch

  • Milestone changed from 5.0 to 4.0

Milestone 5.0 deleted

Note: See TracTickets for help on using tickets.