From 88d34597a3dcee18240a6cc44b373cd9ad0c1527125724e52fa4062f67ae1e08 Mon Sep 17 00:00:00 2001 From: Dominique Leuenberger Date: Wed, 14 Feb 2018 13:18:55 +0000 Subject: [PATCH] Accepting request 576469 from KDE:Extra OBS-URL: https://build.opensuse.org/request/show/576469 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/kio-gdrive?expand=0&rev=8 --- 0001-MIME-type-correction-for-ods-files.patch | 86 +++++++++++++++++++ kio-gdrive.changes | 7 ++ kio-gdrive.spec | 5 +- 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 0001-MIME-type-correction-for-ods-files.patch diff --git a/0001-MIME-type-correction-for-ods-files.patch b/0001-MIME-type-correction-for-ods-files.patch new file mode 100644 index 0000000..9a5f127 --- /dev/null +++ b/0001-MIME-type-correction-for-ods-files.patch @@ -0,0 +1,86 @@ +From 69bc358d195c411e21630b8f8cbaed05ee9f5838 Mon Sep 17 00:00:00 2001 +From: Martijn Schmidt +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 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 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 + diff --git a/kio-gdrive.changes b/kio-gdrive.changes index 5577329..0a83bbc 100644 --- a/kio-gdrive.changes +++ b/kio-gdrive.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Tue Feb 13 17:51:49 UTC 2018 - alarrosa@suse.com + +- Add patch to fix opening ods files using kio-gdrive, since the file + has an invalid MIME type x-vnd.oasis.opendocument.spreadsheet (kde#388598) + * 0001-MIME-type-correction-for-ods-files.patch + ------------------------------------------------------------------- Sun Oct 1 11:56:00 UTC 2017 - wbauer@tmo.at diff --git a/kio-gdrive.spec b/kio-gdrive.spec index d7ad30f..b9e47ff 100644 --- a/kio-gdrive.spec +++ b/kio-gdrive.spec @@ -1,7 +1,7 @@ # # spec file for package kio-gdrive # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -25,6 +25,8 @@ License: GPL-2.0+ Group: System/GUI/KDE Url: http://www.kde.org Source: http://download.kde.org/stable/%{name}/%{version}/src/%{name}-%{version}.tar.xz +# FIX-PATCH-UPSTREAM Fixed in 1.2.2 +Patch0: 0001-MIME-type-correction-for-ods-files.patch BuildRequires: extra-cmake-modules BuildRequires: intltool BuildRequires: kaccounts-integration-devel @@ -52,6 +54,7 @@ This can be Dolphin or Gwenview or Konqueror. %prep %setup -q +%patch0 -p1 %build %cmake_kf5 -d build