mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
Fix dynamic loading of LibreOffice extensions
HWPX MIME type is recognized as 'application/zip' with current version of file command (file-5.44). It will be recognized as 'application/hwp+zip' when new version of file is released. For a temporary fix, when MIME type of file is 'application/zip', check the file type again (without the MIME option). And then check if it's 'Zip data (MIME type "application/hwp+zip"?)' or not.
This commit is contained in:
parent
d16961bed6
commit
a453c890a0
1 changed files with 8 additions and 12 deletions
|
@ -78,10 +78,6 @@ class DocumentToPixels(DangerzoneConverter):
|
|||
"type": "libreoffice",
|
||||
},
|
||||
# .hwp
|
||||
"application/vnd.hancom.hwp": {
|
||||
"type": "libreoffice",
|
||||
"libreoffice_ext": "h2orestart.oxt",
|
||||
},
|
||||
"application/haansofthwp": {
|
||||
"type": "libreoffice",
|
||||
"libreoffice_ext": "h2orestart.oxt",
|
||||
|
@ -91,16 +87,9 @@ class DocumentToPixels(DangerzoneConverter):
|
|||
"libreoffice_ext": "h2orestart.oxt",
|
||||
},
|
||||
# .hwpx
|
||||
"application/vnd.hancom.hwpx": {
|
||||
"type": "libreoffice",
|
||||
"libreoffice_ext": "h2orestart.oxt",
|
||||
},
|
||||
"application/haansofthwpx": {
|
||||
"type": "libreoffice",
|
||||
"libreoffice_ext": "h2orestart.oxt",
|
||||
},
|
||||
"application/hwp+zip": {
|
||||
"type": "libreoffice",
|
||||
"libreoffice_ext": "h2orestart.oxt",
|
||||
},
|
||||
# At least .odt, .docx, .odg, .odp, .ods, and .pptx
|
||||
"application/zip": {
|
||||
|
@ -136,6 +125,13 @@ class DocumentToPixels(DangerzoneConverter):
|
|||
if mime_type not in conversions:
|
||||
raise ValueError("The document format is not supported")
|
||||
|
||||
# Temporary fix for the HWPX format
|
||||
if mime_type == "application/zip":
|
||||
file_type = magic.from_file("/tmp/input_file")
|
||||
hwpx_file_type = 'Zip data (MIME type "application/hwp+zip"?)'
|
||||
if file_type == hwpx_file_type:
|
||||
mime_type = "application/hwp+zip"
|
||||
|
||||
# Get file size (in MiB)
|
||||
size = os.path.getsize("/tmp/input_file") / 1024**2
|
||||
|
||||
|
|
Loading…
Reference in a new issue