mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +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",
|
"type": "libreoffice",
|
||||||
},
|
},
|
||||||
# .hwp
|
# .hwp
|
||||||
"application/haansofthwp": {
|
# Commented MIMEs are not used in `file` and don't conform to the rules.
|
||||||
"type": "libreoffice",
|
# Left them for just in case
|
||||||
"libreoffice_ext": "h2orestart.oxt",
|
# 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": {
|
"application/x-hwp": {
|
||||||
"type": "libreoffice",
|
"type": "libreoffice",
|
||||||
"libreoffice_ext": "h2orestart.oxt",
|
"libreoffice_ext": "h2orestart.oxt",
|
||||||
},
|
},
|
||||||
# .hwpx
|
# .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": {
|
"application/hwp+zip": {
|
||||||
"type": "libreoffice",
|
"type": "libreoffice",
|
||||||
"libreoffice_ext": "h2orestart.oxt",
|
"libreoffice_ext": "h2orestart.oxt",
|
||||||
|
@ -126,11 +145,12 @@ class DocumentToPixels(DangerzoneConverter):
|
||||||
raise ValueError("The document format is not supported")
|
raise ValueError("The document format is not supported")
|
||||||
|
|
||||||
# Temporary fix for the HWPX format
|
# Temporary fix for the HWPX format
|
||||||
|
# Should be removed after new release of `file' (current release 5.44)
|
||||||
if mime_type == "application/zip":
|
if mime_type == "application/zip":
|
||||||
file_type = magic.from_file("/tmp/input_file")
|
file_type = magic.from_file("/tmp/input_file")
|
||||||
hwpx_file_type = 'Zip data (MIME type "application/hwp+zip"?)'
|
hwpx_file_type = 'Zip data (MIME type "application/hwp+zip"?)'
|
||||||
if file_type == hwpx_file_type:
|
if file_type == hwpx_file_type:
|
||||||
mime_type = "application/hwp+zip"
|
mime_type = "application/x-hwp+zip"
|
||||||
|
|
||||||
# Get file size (in MiB)
|
# Get file size (in MiB)
|
||||||
size = os.path.getsize("/tmp/input_file") / 1024**2
|
size = os.path.getsize("/tmp/input_file") / 1024**2
|
||||||
|
|
|
@ -143,16 +143,19 @@ if p == "Darwin":
|
||||||
"CFBundleTypeName": "ODF Graphics Document",
|
"CFBundleTypeName": "ODF Graphics Document",
|
||||||
"CFBundleTypeRole": "Viewer",
|
"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"],
|
"CFBundleTypeExtensions": ["hwp", "hwpx"],
|
||||||
"CFBundleTypeIconFile": "../macos/document.icns",
|
"CFBundleTypeIconFile": "../macos/document.icns",
|
||||||
"CFBundleTypeMIMETypes": [
|
"CFBundleTypeMIMETypes": [
|
||||||
"application/vnd.hancom.hwp",
|
#"application/vnd.hancom.hwp",
|
||||||
"application/haansofthwp",
|
#"application/haansofthwp",
|
||||||
"application/x-hwp",
|
"application/x-hwp",
|
||||||
"application/vnd.hancom.hwpx",
|
#"application/vnd.hancom.hwpx",
|
||||||
"application/haansofthwpx",
|
#"application/haansofthwpx",
|
||||||
"application/hwp+zip",
|
"application/hwp+zip",
|
||||||
|
"application/x-hwp+zip",
|
||||||
],
|
],
|
||||||
"CFBundleTypeName": "Hancom Office Document",
|
"CFBundleTypeName": "Hancom Office Document",
|
||||||
"CFBundleTypeRole": "Viewer",
|
"CFBundleTypeRole": "Viewer",
|
||||||
|
|
Loading…
Reference in a new issue