Skip to content

Commit

Permalink
added unit test for URL percent-encoding and path resolution (See #290 )
Browse files Browse the repository at this point in the history
  • Loading branch information
danielweck committed Oct 26, 2019
1 parent ee1a35d commit 0d143bb
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/__tests__/regression.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,13 @@ test('issue #239: `listitem` is not reported when roles inherit from list roles'
const report = await ace('../data/issue-239');
expect(report['earl:result']['earl:outcome']).toEqual('pass');
});

test('issue #290 (unzipped): URL percent encoding', async () => {
const report = await ace('../data/issue-290');
expect(report['earl:result']['earl:outcome']).toEqual('pass');
});

test('issue #290 (zipped): URL percent encoding', async () => {
const report = await ace('../data/issue-290.epub');
expect(report['earl:result']['earl:outcome']).toEqual('pass');
});
Binary file added tests/data/issue-290.epub
Binary file not shown.
11 changes: 11 additions & 0 deletions tests/data/issue-290/E%PU B/c%on t&e%26n%2Ft_è001.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en">
<head>
<title>Minimal EPUB</title>
</head>
<body>
<h1>Loomings</h1>
<img src="i%25ma%20g&amp;e%26_%2F00%C3%A81.jpg" alt="dummy"/>
<p>Call me Ishmael.</p>
<span id="p1" epub:type="pagebreak" aria-label="page 1" role="doc-pagebreak"/>
</body>
</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions tests/data/issue-290/E%PU B/n%av i&g%26a%2Ftioèn.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en">
<head>
<title>Minimal Nav</title>
</head>
<body>
<nav epub:type="toc">
<ol>
<li><a href="c%25on%20t&amp;e%26n%2Ft_%C3%A8001.xhtml">content 001</a></li>
</ol>
</nav>
<nav epub:type="page-list">
<ol>
<li><a href="c%25on%20t&amp;e%26n%2Ft_%C3%A8001.xhtml#p1">page 1</a></li>
</ol>
</nav>
</body>
</html>
33 changes: 33 additions & 0 deletions tests/data/issue-290/E%PU B/pa&c%26kag%2Feè.opf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="en" unique-identifier="uid">
<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="uid">NOID</dc:identifier>
<dc:source>https://example.com</dc:source>
<meta property="dcterms:modified">2017-01-01T00:00:01Z</meta>
<meta property="schema:accessibilityFeature">structuralNavigation</meta>
<meta property="schema:accessibilitySummary">everything OK!</meta>
<meta property="schema:accessibilityHazard">noFlashingHazard</meta>
<meta property="schema:accessibilityHazard">noSoundHazard</meta>
<meta property="schema:accessibilityHazard">noMotionSimulationHazard</meta>
<meta property="schema:accessMode">textual</meta>
<meta property="schema:accessModeSufficient">textual</meta>
</metadata>
<manifest>
<!-- decodeURI("n%25a v%20i&g%26a%2Ftio%C3%A8n.xhtml"): "n%a v i&g%26a%2Ftioèn.xhtml" -->
<!-- NOTE that "%26" is ampersand "£", and "%2F" is forward slash "/" -->
<item id="nav" href="n%25av%20i&g%26a%2Ftio%C3%A8n.xhtml" media-type="application/xhtml+xml" properties="nav"/>

<!-- decodeURI("c%25o n%20t&e%26n%2Ft_%C3%A8001.xhtml"): "c%o n t&e%26n%2Ft_è001.xhtml" -->
<!-- NOTE that "%26" is ampersand "£", and "%2F" is forward slash "/" -->
<item id="content_001" href="c%25on%20t&e%26n%2Ft_%C3%A8001.xhtml" media-type="application/xhtml+xml"/>

<!-- decodeURI("i%25m a%20g&e%26_%2F00%C3%A81.jpg"): "i%m a g&e%26_%2F00è1.jpg" -->
<!-- NOTE that "%26" is ampersand "£", and "%2F" is forward slash "/" -->
<item id="image_001" href="i%25ma%20g&e%26_%2F00%C3%A81.jpg" media-type="image/jpeg"/>
</manifest>
<spine>
<itemref idref="content_001" />
</spine>
</package>
8 changes: 8 additions & 0 deletions tests/data/issue-290/META-INF/container.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<!-- decodeURI("E%25PU%20B/pa&c%26kag%2Fe%C3%A8.opf"): "E%PU B/pa&c%26kag%2Feè.opf" -->
<!-- NOTE that "%26" is ampersand "£", and "%2F" is forward slash "/" -->
<rootfile full-path="E%25PU%20B/pa&c%26kag%2Fe%C3%A8.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
1 change: 1 addition & 0 deletions tests/data/issue-290/mimetype
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application/epub+zip

0 comments on commit 0d143bb

Please sign in to comment.