mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 09:52:37 +02:00
Clean up HWP/HWPX MIME types
Use the MIME types actually used by the `file` command, which was
recently changed for the detection of the HWPX format [1].
application/hwp+zip -> application/x-hwp+zip
But the HWPX format includes a 'mimetype' file, which contains the
MIME type string "application/hwp+zip", so that was left so because
it may be possible to detect it as "application/hwp+zip".
[1]: ceef7ead3a
This commit is contained in:
parent
a453c890a0
commit
fa22e96af7
2 changed files with 32 additions and 9 deletions
|
@ -78,15 +78,34 @@ class DocumentToPixels(DangerzoneConverter):
|
|||
"type": "libreoffice",
|
||||
},
|
||||
# .hwp
|
||||
"application/haansofthwp": {
|
||||
"type": "libreoffice",
|
||||
"libreoffice_ext": "h2orestart.oxt",
|
||||
},
|
||||
# Commented MIMEs are not used in `file` and don't conform to the rules.
|
||||
# Left them for just in case
|
||||
# PR: https://github.com/freedomofpress/dangerzone/pull/460
|
||||
# "application/haansofthwp": {
|
||||
# "type": "libreoffice",
|
||||
# "libreoffice_ext": "h2orestart.oxt",
|
||||
# },
|
||||
# "application/vnd.hancom.hwp": {
|
||||
# "type": "libreoffice",
|
||||
# "libreoffice_ext": "h2orestart.oxt",
|
||||
# },
|
||||
"application/x-hwp": {
|
||||
"type": "libreoffice",
|
||||
"libreoffice_ext": "h2orestart.oxt",
|
||||
},
|
||||
# .hwpx
|
||||
# "application/haansofthwpx": {
|
||||
# "type": "libreoffice",
|
||||
# "libreoffice_ext": "h2orestart.oxt",
|
||||
# },
|
||||
# "application/vnd.hancom.hwpx": {
|
||||
# "type": "libreoffice",
|
||||
# "libreoffice_ext": "h2orestart.oxt",
|
||||
# },
|
||||
"application/x-hwp+zip": {
|
||||
"type": "libreoffice",
|
||||
"libreoffice_ext": "h2orestart.oxt",
|
||||
},
|
||||
"application/hwp+zip": {
|
||||
"type": "libreoffice",
|
||||
"libreoffice_ext": "h2orestart.oxt",
|
||||
|
@ -126,11 +145,12 @@ class DocumentToPixels(DangerzoneConverter):
|
|||
raise ValueError("The document format is not supported")
|
||||
|
||||
# Temporary fix for the HWPX format
|
||||
# Should be removed after new release of `file' (current release 5.44)
|
||||
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"
|
||||
mime_type = "application/x-hwp+zip"
|
||||
|
||||
# Get file size (in MiB)
|
||||
size = os.path.getsize("/tmp/input_file") / 1024**2
|
||||
|
|
|
@ -143,16 +143,19 @@ if p == "Darwin":
|
|||
"CFBundleTypeName": "ODF Graphics Document",
|
||||
"CFBundleTypeRole": "Viewer",
|
||||
},
|
||||
# Commented MIMEs are not used in `file` and don't conform to the rules.
|
||||
# Left them for just in case
|
||||
{
|
||||
"CFBundleTypeExtensions": ["hwp", "hwpx"],
|
||||
"CFBundleTypeIconFile": "../macos/document.icns",
|
||||
"CFBundleTypeMIMETypes": [
|
||||
"application/vnd.hancom.hwp",
|
||||
"application/haansofthwp",
|
||||
#"application/vnd.hancom.hwp",
|
||||
#"application/haansofthwp",
|
||||
"application/x-hwp",
|
||||
"application/vnd.hancom.hwpx",
|
||||
"application/haansofthwpx",
|
||||
#"application/vnd.hancom.hwpx",
|
||||
#"application/haansofthwpx",
|
||||
"application/hwp+zip",
|
||||
"application/x-hwp+zip",
|
||||
],
|
||||
"CFBundleTypeName": "Hancom Office Document",
|
||||
"CFBundleTypeRole": "Viewer",
|
||||
|
|
Loading…
Reference in a new issue