diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-09-08 17:57:23 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-09-08 19:19:41 +0200 |
commit | 44786fad67cf48f6091e868cf0476e754650d385 (patch) | |
tree | f7d9067b6bfdcf3c605c40b3cdd1097b84c7fd68 /external/libepubgen | |
parent | 6e260dbebc91f137d6f797dd10d64e53a063dc0b (diff) |
EPUB export: avoid writing image/x-vclgraphic to the output file
The spec has a fixed list of allowed MIME types.
Change-Id: I99a3121e41a2f6a3d0c5a040d66302161b16b0fb
Reviewed-on: https://gerrit.libreoffice.org/42116
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'external/libepubgen')
-rw-r--r-- | external/libepubgen/libepubgen-epub3.patch.1 | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/external/libepubgen/libepubgen-epub3.patch.1 b/external/libepubgen/libepubgen-epub3.patch.1 index 8e62660ea566..0fdf0c72f070 100644 --- a/external/libepubgen/libepubgen-epub3.patch.1 +++ b/external/libepubgen/libepubgen-epub3.patch.1 @@ -1935,3 +1935,62 @@ index aa09332..ed968bf 100644 -- 2.12.3 +From 7cf3c6541a61f9d74cd51fb2a01344df783cb26d Mon Sep 17 00:00:00 2001 +From: Miklos Vajna <vmiklos@collabora.co.uk> +Date: Fri, 8 Sep 2017 16:25:36 +0200 +Subject: [PATCH] EPUBTextGenerator: ignore invalid media types + +This assumes there is no image type that is valid in EPUB2, but not in +EPUB3. +--- + src/lib/EPUBTextGenerator.cpp | 26 +++++++++++++++++++++++++- + src/test/EPUBTextGeneratorTest.cpp | 23 +++++++++++++++++++++++ + 2 files changed, 48 insertions(+), 1 deletion(-) + +diff --git a/src/lib/EPUBTextGenerator.cpp b/src/lib/EPUBTextGenerator.cpp +index 0f7f1e0..1bd1e16 100644 +--- a/src/lib/EPUBTextGenerator.cpp ++++ b/src/lib/EPUBTextGenerator.cpp +@@ -595,6 +595,27 @@ void EPUBTextGenerator::closeFrame() + m_impl->getHtml()->closeFrame(); + } + ++/// Checks if the media type is an EPUB 3 Core Media Type or not. ++static bool isValidMimeType(const RVNGString& mediaType) ++{ ++ // Defined at <https://idpf.github.io/epub-cmt/v3/#sec-cmt-supported>. ++ static char const *(types[])= ++ { ++ "image/gif", ++ "image/png", ++ "image/jpeg", ++ "image/svg+xml" ++ }; ++ ++ for (const auto& i : types) ++ { ++ if (mediaType == i) ++ return true; ++ } ++ ++ return false; ++} ++ + void EPUBTextGenerator::insertBinaryObject(const librevenge::RVNGPropertyList &propList) + { + if (m_impl->getSplitGuard().splitOnSize()) +@@ -607,7 +628,10 @@ void EPUBTextGenerator::insertBinaryObject(const librevenge::RVNGPropertyList &p + for (RVNGPropertyList::Iter iter(propList); !iter.last(); iter.next()) + { + if (RVNGString("librevenge:mime-type") == iter.key()) +- mimetype.reset(iter()->clone()); ++ { ++ if (isValidMimeType(iter()->getStr())) ++ mimetype.reset(iter()->clone()); ++ } + else if (RVNGString("office:binary-data") == iter.key()) + data.reset(iter()->clone()); + else +-- +2.12.3 + |