|
|
|
@@ -1,86 +0,0 @@
|
|
|
|
|
From 69bc358d195c411e21630b8f8cbaed05ee9f5838 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: Martijn Schmidt <martijn.schmidt@gmail.com>
|
|
|
|
|
Date: Sat, 10 Feb 2018 17:49:36 +0100
|
|
|
|
|
Subject: MIME type correction for .ods files in src/gdrivehelper.cpp
|
|
|
|
|
|
|
|
|
|
Summary:
|
|
|
|
|
KIO-GDrive appears to assign the mime type "application/x-vnd.oasis.opendocument.spreadsheet"
|
|
|
|
|
to .ods files in src/gdrivehelper.cpp.
|
|
|
|
|
However, the correct mime type is "application/vnd.oasis.opendocument.spreadsheet".
|
|
|
|
|
|
|
|
|
|
References:
|
|
|
|
|
https://wiki.documentfoundation.org/Faq/General/036
|
|
|
|
|
https://en.wikipedia.org/wiki/OpenDocument_technical_specification#Documents
|
|
|
|
|
|
|
|
|
|
BUG: 388598
|
|
|
|
|
FIXED-IN: 1.2.2
|
|
|
|
|
|
|
|
|
|
Test Plan:
|
|
|
|
|
|
|
|
|
|
1. Try to open a .ods file through an unpatched KIO-GDrive and notice how
|
|
|
|
|
you'll receive a Choose Application prompt from Dolphin.
|
|
|
|
|
This is a result of the fact that "application/x-vnd.oasis.opendocument.spreadsheet" is an unknown MIME type.
|
|
|
|
|
|
|
|
|
|
2. Repeat the test described in 1 with the patched KIO-GDrive,
|
|
|
|
|
and notice how (for example) LibreOffice Calc immediately opens the file
|
|
|
|
|
without going through Dolphin's Choose Application prompt first.
|
|
|
|
|
|
|
|
|
|
Differential Revision: https://phabricator.kde.org/D9706
|
|
|
|
|
---
|
|
|
|
|
src/gdrivehelper.cpp | 19 +++++++++++++++----
|
|
|
|
|
1 file changed, 15 insertions(+), 4 deletions(-)
|
|
|
|
|
|
|
|
|
|
diff --git a/src/gdrivehelper.cpp b/src/gdrivehelper.cpp
|
|
|
|
|
index 73f755f..c52f37e 100644
|
|
|
|
|
--- a/src/gdrivehelper.cpp
|
|
|
|
|
+++ b/src/gdrivehelper.cpp
|
|
|
|
|
@@ -35,7 +35,12 @@ using namespace KGAPI2::Drive;
|
|
|
|
|
|
|
|
|
|
#define VND_OASIS_OPENDOCUMENT_TEXT QStringLiteral("application/vnd.oasis.opendocument.text")
|
|
|
|
|
#define VND_OASIS_OPENDOCUMENT_PRESENTATION QStringLiteral("application/vnd.oasis.opendocument.presentation")
|
|
|
|
|
-#define VND_OASIS_OPENDOCUMENT_SPREADSHEED QStringLiteral("application/x-vnd.oasis.opendocument.spreadsheet")
|
|
|
|
|
+// Google's Drive API v2 mistakenly documents an x-vnd style MIME type
|
|
|
|
|
+// for .ods files, so we #define both the correct but undocumented,
|
|
|
|
|
+// as well as the incorrect but publicly documented MIME type.
|
|
|
|
|
+#define VND_OASIS_OPENDOCUMENT_SPREADSHEET QStringLiteral("application/vnd.oasis.opendocument.spreadsheet")
|
|
|
|
|
+#define X_VND_OASIS_OPENDOCUMENT_SPREADSHEET QStringLiteral("application/x-vnd.oasis.opendocument.spreadsheet")
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
#define VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_DOCUMENT \
|
|
|
|
|
QStringLiteral("application/vnd.openxmlformats-officedocument.wordprocessingml.document")
|
|
|
|
|
@@ -52,7 +57,7 @@ namespace GDriveHelper {
|
|
|
|
|
|
|
|
|
|
static const QMap<QString /* mimetype */, QString /* .ext */> ExtensionsMap{
|
|
|
|
|
{ VND_OASIS_OPENDOCUMENT_TEXT, QStringLiteral(".odt") },
|
|
|
|
|
- { VND_OASIS_OPENDOCUMENT_SPREADSHEED, QStringLiteral(".ods") },
|
|
|
|
|
+ { VND_OASIS_OPENDOCUMENT_SPREADSHEET, QStringLiteral(".ods") },
|
|
|
|
|
{ VND_OASIS_OPENDOCUMENT_PRESENTATION, QStringLiteral(".odp") },
|
|
|
|
|
{ VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_DOCUMENT, QStringLiteral(".docx") },
|
|
|
|
|
{ VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_SHEET, QStringLiteral(".xlsx") },
|
|
|
|
|
@@ -79,7 +84,7 @@ static const QMap<QString /* mimetype */, QStringList /* target mimetypes */ > C
|
|
|
|
|
APPLICATION_PDF }
|
|
|
|
|
},
|
|
|
|
|
{ VND_GOOGLE_APPS_SPREADSHEET, {
|
|
|
|
|
- VND_OASIS_OPENDOCUMENT_SPREADSHEED,
|
|
|
|
|
+ VND_OASIS_OPENDOCUMENT_SPREADSHEET,
|
|
|
|
|
VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_SHEET,
|
|
|
|
|
APPLICATION_PDF }
|
|
|
|
|
}
|
|
|
|
|
@@ -109,7 +114,13 @@ QUrl GDriveHelper::convertFromGDocs(KGAPI2::Drive::FilePtr &file)
|
|
|
|
|
Q_FOREACH (const QString &targetMimeType, convIt.value()) {
|
|
|
|
|
const auto linkIt = exportLinks.constFind(targetMimeType);
|
|
|
|
|
if (linkIt != exportLinks.cend()) {
|
|
|
|
|
- file->setMimeType(targetMimeType);
|
|
|
|
|
+ // Extra check to safeguard against a mistake in Google's Drive API v2
|
|
|
|
|
+ // documentation which lists an invalid MIME type for .ods files.
|
|
|
|
|
+ if (targetMimeType == X_VND_OASIS_OPENDOCUMENT_SPREADSHEET) {
|
|
|
|
|
+ file->setMimeType(VND_OASIS_OPENDOCUMENT_SPREADSHEET);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ file->setMimeType(targetMimeType);
|
|
|
|
|
+ }
|
|
|
|
|
file->setTitle(file->title() + GDriveHelper::ExtensionsMap[targetMimeType]);
|
|
|
|
|
return *linkIt;
|
|
|
|
|
}
|
|
|
|
|
--
|
|
|
|
|
cgit v0.11.2
|
|
|
|
|
|