T0ha / ezodf

ezodf is a Python package to create new or open existing OpenDocument (ODF) files to extract, add, modify or delete document data, forked from dead project https://bitbucket.org/mozman/ezodf
Other
61 stars 23 forks source link

__detect_mime_type is broken #35

Open weddige opened 1 year ago

weddige commented 1 year ago

__detect_mime_type has a bug in line 66/67:

https://github.com/T0ha/ezodf/blob/f9675c165679290a15bd2f9ab75f90fbc1490668/ezodf/document.py#L56-L68

os.path.splitext returns the file extension with a leading dot (e. g. .ods). But MIMETYPES only contains the extensions without the dot:https://github.com/T0ha/ezodf/blob/f9675c165679290a15bd2f9ab75f90fbc1490668/ezodf/const.py#L23

kenchou commented 1 year ago

emmm, This function is introduced by me...

ext = os.path.splitext(file_manager.zipname)[1] should be ext = os.path.splitext(file_manager.zipname)[1][1:]

I will create a PR later.