Skip to content

Commit

Permalink
fix: mailto URLs were reported as missing resources
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rdeltour committed Jan 10, 2025
1 parent c0c3866 commit 70d10ac
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/com/adobe/epubcheck/ocf/OCFContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html xmlns:epub="http://www.idpf.org/2007/ops" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8"/>
<title>Minimal EPUB</title>
</head>
<body>
<h1>Loomings</h1>
<p>Call me <a href="mailto:[email protected]">Ishmael</a>.</p>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
<head>
<meta charset="utf-8"/>
<title>Minimal Nav</title>
</head>
<body>
<nav epub:type="toc">
<ol>
<li><a href="content_001.xhtml">content 001</a></li>
</ol>
</nav>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="q">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title id="title">Minimal EPUB 3.0</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="q">NOID</dc:identifier>
<meta property="dcterms:modified">2017-06-14T00:00:01Z</meta>
</metadata>
<manifest>
<item id="content_001" href="content_001.xhtml" media-type="application/xhtml+xml"/>
<item id="nav" href="nav.xhtml" media-type="application/xhtml+xml" properties="nav"/>
</manifest>
<spine>
<itemref idref="content_001" />
</spine>
</package>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="EPUB/package.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application/epub+zip
4 changes: 4 additions & 0 deletions src/test/resources/epub3/03-resources/resources.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 70d10ac

Please sign in to comment.