From 70d10ac84ddf1946849b39213db7d48266622e83 Mon Sep 17 00:00:00 2001 From: Romain Deltour Date: Fri, 10 Jan 2025 10:45:38 +0100 Subject: [PATCH] fix: `mailto` URLs were reported as missing resources Fix a regression bug introduced in PR #1582, in the implementatiom of `OCFContainer#isRemote(URL)`. The buggy implementation considered `mailto` URLs as local URLs. As a result, it reported an error as no matching local resource could be found in the container. The new implementation says a URL is remote when it is not a `data` URL and is not the URL of a resource in the container. Fix #1595 --- .../com/adobe/epubcheck/ocf/OCFContainer.java | 2 +- .../mailto-url-valid/EPUB/content_001.xhtml | 11 +++++++++++ .../files/mailto-url-valid/EPUB/nav.xhtml | 14 ++++++++++++++ .../files/mailto-url-valid/EPUB/package.opf | 16 ++++++++++++++++ .../mailto-url-valid/META-INF/container.xml | 6 ++++++ .../03-resources/files/mailto-url-valid/mimetype | 1 + .../epub3/03-resources/resources.feature | 4 ++++ 7 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/epub3/03-resources/files/mailto-url-valid/EPUB/content_001.xhtml create mode 100644 src/test/resources/epub3/03-resources/files/mailto-url-valid/EPUB/nav.xhtml create mode 100644 src/test/resources/epub3/03-resources/files/mailto-url-valid/EPUB/package.opf create mode 100644 src/test/resources/epub3/03-resources/files/mailto-url-valid/META-INF/container.xml create mode 100644 src/test/resources/epub3/03-resources/files/mailto-url-valid/mimetype diff --git a/src/main/java/com/adobe/epubcheck/ocf/OCFContainer.java b/src/main/java/com/adobe/epubcheck/ocf/OCFContainer.java index 554d3f2e8..6c643d0ea 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 (!url.isHierarchical() || contains(url)) + if ("data".equals(url.scheme()) || contains(url)) { return false; } diff --git a/src/test/resources/epub3/03-resources/files/mailto-url-valid/EPUB/content_001.xhtml b/src/test/resources/epub3/03-resources/files/mailto-url-valid/EPUB/content_001.xhtml new file mode 100644 index 000000000..1a00a6140 --- /dev/null +++ b/src/test/resources/epub3/03-resources/files/mailto-url-valid/EPUB/content_001.xhtml @@ -0,0 +1,11 @@ + + + + + Minimal EPUB + + +

Loomings

+

Call me Ishmael.

+ + diff --git a/src/test/resources/epub3/03-resources/files/mailto-url-valid/EPUB/nav.xhtml b/src/test/resources/epub3/03-resources/files/mailto-url-valid/EPUB/nav.xhtml new file mode 100644 index 000000000..240745e63 --- /dev/null +++ b/src/test/resources/epub3/03-resources/files/mailto-url-valid/EPUB/nav.xhtml @@ -0,0 +1,14 @@ + + + + + Minimal Nav + + + + + diff --git a/src/test/resources/epub3/03-resources/files/mailto-url-valid/EPUB/package.opf b/src/test/resources/epub3/03-resources/files/mailto-url-valid/EPUB/package.opf new file mode 100644 index 000000000..0d1eec6e9 --- /dev/null +++ b/src/test/resources/epub3/03-resources/files/mailto-url-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/mailto-url-valid/META-INF/container.xml b/src/test/resources/epub3/03-resources/files/mailto-url-valid/META-INF/container.xml new file mode 100644 index 000000000..318782179 --- /dev/null +++ b/src/test/resources/epub3/03-resources/files/mailto-url-valid/META-INF/container.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/test/resources/epub3/03-resources/files/mailto-url-valid/mimetype b/src/test/resources/epub3/03-resources/files/mailto-url-valid/mimetype new file mode 100644 index 000000000..57ef03f24 --- /dev/null +++ b/src/test/resources/epub3/03-resources/files/mailto-url-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 d9cac61c6..f06c4d23a 100644 --- a/src/test/resources/epub3/03-resources/resources.feature +++ b/src/test/resources/epub3/03-resources/resources.feature @@ -490,6 +490,10 @@ Then warning RSC-031 is reported 3 times And no other errors or warnings are reported + Scenario: Allow `mailto` URLs, do not process them as resources + When checking document 'mailto-url-valid' + Then no errors or warnings are reported + ## 3.7 Data URLs @spec @xref:sec-data-urls