diff --git a/src/main/java/com/adobe/epubcheck/ocf/OCFContainer.java b/src/main/java/com/adobe/epubcheck/ocf/OCFContainer.java index ebaf4d087..554d3f2e8 100644 --- a/src/main/java/com/adobe/epubcheck/ocf/OCFContainer.java +++ b/src/main/java/com/adobe/epubcheck/ocf/OCFContainer.java @@ -131,7 +131,7 @@ public String relativize(URL url) public boolean isRemote(URL url) { Preconditions.checkArgument(url != null, "URL is null"); - if (contains(url)) + if (!url.isHierarchical() || contains(url)) { return false; } diff --git a/src/main/java/org/w3c/epubcheck/core/references/ReferenceRegistry.java b/src/main/java/org/w3c/epubcheck/core/references/ReferenceRegistry.java index 7c7662d06..1e36ff211 100644 --- a/src/main/java/org/w3c/epubcheck/core/references/ReferenceRegistry.java +++ b/src/main/java/org/w3c/epubcheck/core/references/ReferenceRegistry.java @@ -49,7 +49,10 @@ public void registerReference(URL url, Type type, EPUBLocation location, if (url == null) return; // Remove query component of local URLs - if (url.query() != null && !container.isRemote(url)) + // Note: we only do this for hierarchical URLs, to work around a bug + // in Galimatias that would transform a non-hierarchical URL into a + // hierarchical one. Queries for data URLs can safely be ignored here. + if (url.isHierarchical() && url.query() != null && !container.isRemote(url)) { try { diff --git a/src/test/resources/epub3/03-resources/files/data-url-with-unescaped-query-valid/EPUB/content_001.xhtml b/src/test/resources/epub3/03-resources/files/data-url-with-unescaped-query-valid/EPUB/content_001.xhtml new file mode 100644 index 000000000..5ad0c107d --- /dev/null +++ b/src/test/resources/epub3/03-resources/files/data-url-with-unescaped-query-valid/EPUB/content_001.xhtml @@ -0,0 +1,13 @@ + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + + diff --git a/src/test/resources/epub3/03-resources/files/data-url-with-unescaped-query-valid/EPUB/nav.xhtml b/src/test/resources/epub3/03-resources/files/data-url-with-unescaped-query-valid/EPUB/nav.xhtml new file mode 100644 index 000000000..240745e63 --- /dev/null +++ b/src/test/resources/epub3/03-resources/files/data-url-with-unescaped-query-valid/EPUB/nav.xhtml @@ -0,0 +1,14 @@ + + + + + Minimal Nav + + + + + diff --git a/src/test/resources/epub3/03-resources/files/data-url-with-unescaped-query-valid/EPUB/package.opf b/src/test/resources/epub3/03-resources/files/data-url-with-unescaped-query-valid/EPUB/package.opf new file mode 100644 index 000000000..0d1eec6e9 --- /dev/null +++ b/src/test/resources/epub3/03-resources/files/data-url-with-unescaped-query-valid/EPUB/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/epub3/03-resources/files/data-url-with-unescaped-query-valid/META-INF/container.xml b/src/test/resources/epub3/03-resources/files/data-url-with-unescaped-query-valid/META-INF/container.xml new file mode 100644 index 000000000..318782179 --- /dev/null +++ b/src/test/resources/epub3/03-resources/files/data-url-with-unescaped-query-valid/META-INF/container.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/test/resources/epub3/03-resources/files/data-url-with-unescaped-query-valid/mimetype b/src/test/resources/epub3/03-resources/files/data-url-with-unescaped-query-valid/mimetype new file mode 100644 index 000000000..57ef03f24 --- /dev/null +++ b/src/test/resources/epub3/03-resources/files/data-url-with-unescaped-query-valid/mimetype @@ -0,0 +1 @@ +application/epub+zip \ No newline at end of file diff --git a/src/test/resources/epub3/03-resources/resources.feature b/src/test/resources/epub3/03-resources/resources.feature index 51a20fb00..d9cac61c6 100644 --- a/src/test/resources/epub3/03-resources/resources.feature +++ b/src/test/resources/epub3/03-resources/resources.feature @@ -549,6 +549,12 @@ Then error RSC-032 is reported And no other errors or warnings are reported + @spec @xref:sec-data-urls + Scenario: Verify a data URL having unesapced query-like component + See https://github.com/w3c/epubcheck/issues/1536 + When checking EPUB 'data-url-with-unescaped-query-valid' + Then no other errors or warnings are reported + ## 3.8 File URLs @spec @xref:sec-file-urls