From 91b84adb5cf6d7f751b8dc6a64a091e9548a259d Mon Sep 17 00:00:00 2001 From: Romain Deltour Date: Thu, 17 Jan 2019 23:23:58 +0100 Subject: [PATCH] fix: `switch` item property doesn't apply to `svg:switch` The `switch` property of Package Documents `item` elements indicates that the described Publication Resource contains one or more instances of the `epub:switch` element. It should not be declared when the EPUB contains SVG using the `svg:switch` element. Fixes #857 --- .../com/adobe/epubcheck/ops/OPSHandler30.java | 2 +- .../api/Epub30CheckExpandedTest.java | 7 ++++++ .../valid/svg-switch/META-INF/container.xml | 6 +++++ .../valid/svg-switch/OPS/content_001.xhtml | 22 +++++++++++++++++++ .../expanded/valid/svg-switch/OPS/nav.xhtml | 19 ++++++++++++++++ .../expanded/valid/svg-switch/OPS/package.opf | 16 ++++++++++++++ .../30/expanded/valid/svg-switch/mimetype | 1 + 7 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/30/expanded/valid/svg-switch/META-INF/container.xml create mode 100644 src/test/resources/30/expanded/valid/svg-switch/OPS/content_001.xhtml create mode 100644 src/test/resources/30/expanded/valid/svg-switch/OPS/nav.xhtml create mode 100644 src/test/resources/30/expanded/valid/svg-switch/OPS/package.opf create mode 100644 src/test/resources/30/expanded/valid/svg-switch/mimetype diff --git a/src/main/java/com/adobe/epubcheck/ops/OPSHandler30.java b/src/main/java/com/adobe/epubcheck/ops/OPSHandler30.java index 6590269e3..84ed58854 100644 --- a/src/main/java/com/adobe/epubcheck/ops/OPSHandler30.java +++ b/src/main/java/com/adobe/epubcheck/ops/OPSHandler30.java @@ -245,7 +245,7 @@ else if (name.equals("script")) { requiredProperties.add(ITEM_PROPERTIES.SCRIPTED); } - else if (!context.mimeType.equals("image/svg+xml") && name.equals("switch")) + else if (EpubConstants.EpubTypeNamespaceUri.equals(e.getNamespace()) && name.equals("switch")) { requiredProperties.add(ITEM_PROPERTIES.SWITCH); } diff --git a/src/test/java/com/adobe/epubcheck/api/Epub30CheckExpandedTest.java b/src/test/java/com/adobe/epubcheck/api/Epub30CheckExpandedTest.java index 7bf940d1d..d531b6efa 100644 --- a/src/test/java/com/adobe/epubcheck/api/Epub30CheckExpandedTest.java +++ b/src/test/java/com/adobe/epubcheck/api/Epub30CheckExpandedTest.java @@ -418,6 +418,13 @@ public void testValidateEPUB30_svgReferenced() testValidateDocument("valid/svg-referenced/"); } + @Test + public void testValidateEPUB30_svgSwitch() + { + // tests that svg:switch doesn't trigger the OPF 'switch' property check + testValidateDocument("valid/svg-switch/"); + } + @Test public void testValidateEPUB30_videoAudioTrigger() { diff --git a/src/test/resources/30/expanded/valid/svg-switch/META-INF/container.xml b/src/test/resources/30/expanded/valid/svg-switch/META-INF/container.xml new file mode 100644 index 000000000..cd9945b48 --- /dev/null +++ b/src/test/resources/30/expanded/valid/svg-switch/META-INF/container.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/test/resources/30/expanded/valid/svg-switch/OPS/content_001.xhtml b/src/test/resources/30/expanded/valid/svg-switch/OPS/content_001.xhtml new file mode 100644 index 000000000..fcf046a09 --- /dev/null +++ b/src/test/resources/30/expanded/valid/svg-switch/OPS/content_001.xhtml @@ -0,0 +1,22 @@ + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + + +

foo

+
+ + bar + +
+
+ + diff --git a/src/test/resources/30/expanded/valid/svg-switch/OPS/nav.xhtml b/src/test/resources/30/expanded/valid/svg-switch/OPS/nav.xhtml new file mode 100644 index 000000000..fb044b8c6 --- /dev/null +++ b/src/test/resources/30/expanded/valid/svg-switch/OPS/nav.xhtml @@ -0,0 +1,19 @@ + + + + + Minimal Nav + + + + + + diff --git a/src/test/resources/30/expanded/valid/svg-switch/OPS/package.opf b/src/test/resources/30/expanded/valid/svg-switch/OPS/package.opf new file mode 100644 index 000000000..7ce8b2f1a --- /dev/null +++ b/src/test/resources/30/expanded/valid/svg-switch/OPS/package.opf @@ -0,0 +1,16 @@ + + + + Minimal EPUB 3.0 + en + NOID + 2017-06-14T00:00:01Z + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/30/expanded/valid/svg-switch/mimetype b/src/test/resources/30/expanded/valid/svg-switch/mimetype new file mode 100644 index 000000000..57ef03f24 --- /dev/null +++ b/src/test/resources/30/expanded/valid/svg-switch/mimetype @@ -0,0 +1 @@ +application/epub+zip \ No newline at end of file