summaryrefslogtreecommitdiffstats
path: root/external/libepubgen/libepubgen-validation1.patch.1
blob: 18707e76205d4d15a315dde8e7f543b8b7eb9822 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
From 96e9786f5aba1078251f36e58feefc8d953cdea0 Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@collabora.co.uk>
Date: Tue, 8 Aug 2017 16:54:24 +0200
Subject: [PATCH 1/3] EPUBGenerator: fix validation error with empty
 dc:identifier element

<http://www.idpf.org/epub/31/spec/epub-packages.html#sec-opf-dcidentifier>
"3.4.3.2.1 The identifier Element" says that the character content is
not optional, so write it.
---
 configure.ac              |  3 +++
 src/lib/EPUBGenerator.cpp | 14 +++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/lib/EPUBGenerator.cpp b/src/lib/EPUBGenerator.cpp
index 0d0f866..507eb14 100644
--- a/src/lib/EPUBGenerator.cpp
+++ b/src/lib/EPUBGenerator.cpp
@@ -7,6 +7,10 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include <boost/uuid/uuid.hpp>
+#include <boost/uuid/uuid_generators.hpp>
+#include <boost/uuid/uuid_io.hpp>
+
 #include "EPUBCSSSink.h"
 #include "EPUBHTMLGenerator.h"
 #include "EPUBGenerator.h"
@@ -193,7 +197,15 @@ void EPUBGenerator::writeRoot()
 
   RVNGPropertyList identifierAttrs;
   identifierAttrs.insert("id", uniqueId);
-  sink.insertEmptyElement("dc:identifier", identifierAttrs);
+  identifierAttrs.insert("opf:scheme", "UUID");
+  sink.openElement("dc:identifier", identifierAttrs);
+  // The identifier element is required to have a unique character content.
+  std::stringstream identifierStream("urn:uuid:");
+  boost::uuids::uuid uuid = boost::uuids::random_generator()();
+  identifierStream << uuid;
+  std::string identifierCharactrs = identifierStream.str();
+  sink.insertCharacters(identifierCharactrs.c_str());
+  sink.closeElement("dc:identifier");
 
   sink.openElement("dc:title");
   sink.closeElement("dc:title");
-- 
2.12.3