Skip to content

Commit

Permalink
Fixes Issue 202.
Browse files Browse the repository at this point in the history
Makes sure that when checking @src on 'source' elements we consider the resource type based on the parent element's name.
  • Loading branch information
rdeltour committed Nov 29, 2012
1 parent 98ce040 commit 5a68cc8
Show file tree
Hide file tree
Showing 14 changed files with 316 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/adobe/epubcheck/ops/OPSHandler30.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ else if (name.equals("canvas"))
else if (name.equals("img"))
processImg(e);

processSrc(e.getName(), e.getAttribute("src"));
processSrc((e.getName()!="source")?e.getName():e.getParent().getName(), e.getAttribute("src"));

checkType(e.getAttributeNS("http://www.idpf.org/2007/ops", "type"));

Expand Down
24 changes: 20 additions & 4 deletions src/test/java/com/adobe/epubcheck/api/Epub30CheckExpandedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,20 +205,26 @@ public void testValidateEPUB30_CSSEncoding_invalid() {

@Test
public void testValidateEPUB30_remoteAudio_valid() {
// audio element with @src attribute
testValidateDocument("valid/lorem-remote/", 0, 0, "valid/lorem-remote.txt");
}

@Test
public void testValidateEPUB30_remoteAudioSources_valid() {
// audio element with sources children
testValidateDocument("valid/lorem-remote-2/", 0, 0);
}

@Test
public void testValidateEPUB30_remoteImg_invalid() {
//remote img, properly declared in opf
//remote resource of invalid type (img) declared in opf
testValidateDocument("invalid/lorem-remote/", 1, 0);
}

@Test
public void testValidateEPUB30_remoteImg_invalid2() {
//remote img, not declared in opf
//we should only get one error here... tbf
testValidateDocument("invalid/lorem-remote-2/", 3, 0);
//remote audio, declared in opf, but missing 'remote-resources' property
testValidateDocument("invalid/lorem-remote-2/", 1, 0);
}

@Test
Expand All @@ -230,6 +236,16 @@ public void testValidateEPUB30_remoteAudio_invalid() {
testValidateDocument("invalid/lorem-remote-3/", 2, 0);
}

@Test
public void testValidateEPUB30_remoteAudioSources_invalid() {
//audio element with a list of source children pointing to remote resources
// not declared in the manifest
// we should only get two errors here:
// the "no fallback" error is extra since no type info
// can be retrieved from the manifest...
testValidateDocument("invalid/lorem-remote-4/", 3, 0);
}

@Test
public void testValidateEPUB30_circularFallback() {
testValidateDocument("invalid/fallbacks-circular/", 5, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<dc:title>Lorem Ipsum</dc:title>
<dc:language>la</dc:language>
<dc:date>2011-09-01</dc:date>
<meta property="dcterms:modified">2011-09-01T17:18:00Z</meta>
<meta property="dcterms:modified">2012-11-29T09:47:05Z</meta>
</metadata>
<manifest>
<item id="t1" href="lorem.xhtml" properties="nav" media-type="application/xhtml+xml" />
<item id="css" href="lorem.css" media-type="text/css" />
<!-- <item id="invalid" href="http://example.org/remote.jpg" media-type="image/jpeg" /> -->
<item id="audio" href="http://example.org/audio.mp4" media-type="audio/mp4" />
</manifest>
<spine>
<itemref idref="t1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
condimentum malesuada. Nulla fringilla vulputate vestibulum. Sed diam dui, fringilla
quis sagittis nec, viverra et nibh.</p>

<img src="http://example.org/remote.jpg" alt="" />
<audio src="http://example.org/audio.mp4"/>

<p>Sed sollicitudin <a href="http://example.org/#foo">accumsan augue</a>, quis pulvinar
sem volutpat at. Vestibulum rutrum bibendum augue sit amet accumsan. Etiam tempus
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
body {
margin-left : 6em;
margin-right : 16em;
color:black;
font-family: arial, helvetica, sans-serif;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="uid">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:identifier id="uid">urn:uuid:ED450261-BB55-4014-B168-37CC68A2AF21</dc:identifier>
<dc:title>Lorem Ipsum</dc:title>
<dc:language>la</dc:language>
<dc:date>2012-11-29</dc:date>
<meta property="dcterms:modified">2012-11-29T09:47:52Z</meta>
</metadata>
<manifest>
<item id="t1" href="lorem.xhtml" properties="nav remote-resources" media-type="application/xhtml+xml" />
<item id="css" href="lorem.css" media-type="text/css" />
<!-- <item id="audio1" href="http://example.com/audio/src-1.mp4" media-type="audio/mp4" />-->
<!-- <item id="audio2" href="http://example.com/audio/src-2.mp4" media-type="audio/mp4" />-->
</manifest>
<spine>
<itemref idref="t1" />
</spine>
</package>
113 changes: 113 additions & 0 deletions src/test/resources/30/expanded/invalid/lorem-remote-4/EPUB/lorem.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="la" lang="la"
xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<title>Lorem Ipsum</title>
<link type="text/css" rel="stylesheet" href="lorem.css" />
</head>
<body>
<h1>Lorem Ipsum</h1>
<section>
<h2>Table of Contents</h2>
<nav epub:type="toc">
<ol>
<li><a href="#ch1">Chapter 1</a></li>
<li><a href="#ch2">Chapter 2</a></li>
</ol>
</nav>
</section>
<section id="ch1">
<h2>Chapter 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vel purus mauris, ut
auctor massa. Pellentesque non nunc risus. Fusce a massa augue. Nunc erat ante,
auctor id varius ac, vestibulum non purus. Quisque non dui in sem consectetur
condimentum non ac quam. Quisque ultricies nulla nec urna fringilla pretium.
Pellentesque dictum pulvinar purus in mattis. Aliquam vestibulum orci sed magna
vestibulum a sollicitudin lectus pharetra. Suspendisse luctus risus imperdiet nunc
condimentum malesuada. Nulla fringilla vulputate vestibulum. Sed diam dui, fringilla
quis sagittis nec, viverra et nibh.</p>

<audio controls="controls">
<source src="http://example.com/audio/src-1.mp4" type="audio/mp4"/>
<source src="http://example.com/audio/src-2.mp4" type="audio/mp4"/>
</audio>

<p>Sed sollicitudin accumsan augue, quis pulvinar sem volutpat at. Vestibulum rutrum
bibendum augue sit amet accumsan. Etiam tempus malesuada libero vestibulum
fringilla. Maecenas diam nulla, ultricies ac sodales vitae, viverra ut velit.
Vivamus posuere, mi sit amet vehicula tempus, nibh purus scelerisque enim, non
vestibulum erat arcu in libero. Aliquam vel convallis nibh. Sed in nisi ipsum. Sed
sed est justo, in lacinia nulla.</p>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed luctus est vel lacus
ullamcorper vestibulum. Mauris est sapien, pharetra id feugiat in, ornare a erat.
Nam consectetur vehicula nisi vel faucibus. Morbi blandit augue nec lacus malesuada
venenatis. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur
ridiculus mus. Maecenas consectetur, odio vitae suscipit ullamcorper, arcu ligula
pellentesque sem, quis rhoncus enim eros id lectus. Nam ornare dui est, vel posuere
metus. Quisque non nisl metus. Pellentesque id mi nunc, in gravida metus. Nullam
neque tellus, ultricies quis laoreet vitae, imperdiet at nunc. Ut laoreet massa quis
quam vulputate et ultricies nibh consectetur. Donec convallis, nulla id ultricies
ullamcorper, diam tortor interdum dolor, vel tempor lectus urna ut est. Praesent
convallis lacus vitae justo lobortis euismod. In at ante elit.</p>

<p>Aenean quis consectetur justo. Nulla nec enim nisl. Etiam rutrum volutpat tellus, a
scelerisque mauris malesuada sit amet. Suspendisse quis urna augue. Proin tempus
hendrerit libero non cursus. Praesent non massa at nisl luctus facilisis. Nullam
pulvinar, ligula eu porta ornare, mi mi accumsan orci, a iaculis tortor lorem quis
dolor. Phasellus ante nibh, pulvinar ac pulvinar eu, pulvinar ac enim.</p>

<p>Donec vel velit id elit volutpat vestibulum vitae a erat. Duis id est id magna
aliquam pretium nec sit amet nibh. Nullam condimentum suscipit felis, sed interdum
felis dictum ac. Phasellus non nisi quis magna pellentesque auctor. Cras risus
lectus, viverra eu fringilla malesuada, rhoncus et est. Etiam rhoncus pharetra
accumsan. Nullam suscipit tellus felis.</p>
</section>
<section id="ch2">
<h2>Chapter 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla laoreet nibh felis.
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia
Curae; Etiam est sapien, dapibus eget gravida nec, accumsan a turpis. Nunc in nisi
ut dolor elementum porttitor. Mauris hendrerit pulvinar tincidunt. Etiam metus
metus, ullamcorper ut varius lacinia, luctus et nibh. Donec ut metus enim, id
faucibus nunc. Quisque ut iaculis mauris. Duis pellentesque nulla ut eros ultricies
quis condimentum eros adipiscing. Sed porta ultrices diam, ut sagittis lectus mattis
a. Phasellus gravida, sapien vitae mollis interdum, dui neque tempor arcu, ac ornare
leo ipsum ut nisl.</p>

<p>Donec porta, odio et aliquet molestie, felis tellus fermentum leo, id interdum magna
massa quis ligula. Integer elementum mauris eget nisl eleifend facilisis nec sit
amet tellus. Morbi consectetur dignissim egestas. Donec pulvinar, enim eu auctor
cursus, turpis arcu venenatis turpis, eu cursus magna nisl sit amet ante. Curabitur
eleifend arcu eget nibh facilisis mattis. Etiam nisl nunc, semper vitae condimentum
sed, viverra sit amet lacus. Curabitur et orci augue. Suspendisse sollicitudin
vulputate risus, sit amet consequat erat mollis eu. Nunc sodales tincidunt
tincidunt.</p>

<p>Aliquam erat volutpat. Aliquam ornare augue et nulla consequat commodo. Quisque
dictum rhoncus orci vel euismod. Proin leo turpis, adipiscing quis facilisis id,
condimentum sed metus. Nullam pellentesque scelerisque est nec tristique. Nunc augue
turpis, consequat non varius quis, aliquam auctor dolor. Cras luctus dignissim justo
sit amet laoreet. Quisque vel ipsum quis massa suscipit vehicula.</p>

<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis
egestas. Vivamus fringilla eleifend magna, vel commodo turpis egestas at.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis
egestas. Sed eu lorem quam, et sagittis libero. Maecenas vel ante id sem bibendum
laoreet nec dignissim justo. Class aptent taciti sociosqu ad litora torquent per
conubia nostra, per inceptos himenaeos. Fusce eu lorem orci, eu viverra nisi. Lorem
ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum dapibus commodo
pellentesque. Maecenas quis est accumsan est interdum pharetra egestas nec lorem.
Nam a lectus sit amet justo facilisis suscipit.</p>

<p>Integer dolor dolor, volutpat id commodo id, gravida id risus. Donec consectetur
sollicitudin sem, non auctor urna pulvinar non. Vivamus ipsum nisi, commodo sed
scelerisque id, porta nec massa. Vestibulum ac risus et augue faucibus fermentum ut
et nisi. Integer tincidunt suscipit ipsum, sed interdum felis mollis sed.
Suspendisse potenti. Praesent et mauris et quam consequat tristique. Morbi mi dolor,
pharetra quis rutrum quis, fringilla in tortor. Sed a nulla vitae leo dapibus
cursus. Aliquam erat volutpat. Integer purus purus, dictum id bibendum at, lobortis
quis metus.</p>
</section>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
<rootfiles>
<rootfile full-path="EPUB/lorem.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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
body {
margin-left : 6em;
margin-right : 16em;
color:black;
font-family: arial, helvetica, sans-serif;
}
19 changes: 19 additions & 0 deletions src/test/resources/30/expanded/valid/lorem-remote-2/EPUB/lorem.opf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" unique-identifier="uid">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:identifier id="uid">urn:uuid:2012-11-29T09:37:34Z</dc:identifier>
<dc:title>Lorem Ipsum</dc:title>
<dc:language>la</dc:language>
<dc:date>2012-11-29</dc:date>
<meta property="dcterms:modified">2012-11-29T09:37:34Z</meta>
</metadata>
<manifest>
<item id="t1" href="lorem.xhtml" properties="nav remote-resources" media-type="application/xhtml+xml" />
<item id="css" href="lorem.css" media-type="text/css" />
<item id="audio1" href="http://example.com/audio/src-1.mp4" media-type="audio/mp4" />
<item id="audio2" href="http://example.com/audio/src-2.mp4" media-type="audio/mp4" />
</manifest>
<spine>
<itemref idref="t1" />
</spine>
</package>
113 changes: 113 additions & 0 deletions src/test/resources/30/expanded/valid/lorem-remote-2/EPUB/lorem.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="la" lang="la"
xmlns:epub="http://www.idpf.org/2007/ops">
<head>
<title>Lorem Ipsum</title>
<link type="text/css" rel="stylesheet" href="lorem.css" />
</head>
<body>
<h1>Lorem Ipsum</h1>
<section>
<h2>Table of Contents</h2>
<nav epub:type="toc">
<ol>
<li><a href="#ch1">Chapter 1</a></li>
<li><a href="#ch2">Chapter 2</a></li>
</ol>
</nav>
</section>
<section id="ch1">
<h2>Chapter 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam vel purus mauris, ut
auctor massa. Pellentesque non nunc risus. Fusce a massa augue. Nunc erat ante,
auctor id varius ac, vestibulum non purus. Quisque non dui in sem consectetur
condimentum non ac quam. Quisque ultricies nulla nec urna fringilla pretium.
Pellentesque dictum pulvinar purus in mattis. Aliquam vestibulum orci sed magna
vestibulum a sollicitudin lectus pharetra. Suspendisse luctus risus imperdiet nunc
condimentum malesuada. Nulla fringilla vulputate vestibulum. Sed diam dui, fringilla
quis sagittis nec, viverra et nibh.</p>

<audio controls="controls">
<source src="http://example.com/audio/src-1.mp4" type="audio/mp4"/>
<source src="http://example.com/audio/src-2.mp4" type="audio/mp4"/>
</audio>

<p>Sed sollicitudin accumsan augue, quis pulvinar sem volutpat at. Vestibulum rutrum
bibendum augue sit amet accumsan. Etiam tempus malesuada libero vestibulum
fringilla. Maecenas diam nulla, ultricies ac sodales vitae, viverra ut velit.
Vivamus posuere, mi sit amet vehicula tempus, nibh purus scelerisque enim, non
vestibulum erat arcu in libero. Aliquam vel convallis nibh. Sed in nisi ipsum. Sed
sed est justo, in lacinia nulla.</p>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed luctus est vel lacus
ullamcorper vestibulum. Mauris est sapien, pharetra id feugiat in, ornare a erat.
Nam consectetur vehicula nisi vel faucibus. Morbi blandit augue nec lacus malesuada
venenatis. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur
ridiculus mus. Maecenas consectetur, odio vitae suscipit ullamcorper, arcu ligula
pellentesque sem, quis rhoncus enim eros id lectus. Nam ornare dui est, vel posuere
metus. Quisque non nisl metus. Pellentesque id mi nunc, in gravida metus. Nullam
neque tellus, ultricies quis laoreet vitae, imperdiet at nunc. Ut laoreet massa quis
quam vulputate et ultricies nibh consectetur. Donec convallis, nulla id ultricies
ullamcorper, diam tortor interdum dolor, vel tempor lectus urna ut est. Praesent
convallis lacus vitae justo lobortis euismod. In at ante elit.</p>

<p>Aenean quis consectetur justo. Nulla nec enim nisl. Etiam rutrum volutpat tellus, a
scelerisque mauris malesuada sit amet. Suspendisse quis urna augue. Proin tempus
hendrerit libero non cursus. Praesent non massa at nisl luctus facilisis. Nullam
pulvinar, ligula eu porta ornare, mi mi accumsan orci, a iaculis tortor lorem quis
dolor. Phasellus ante nibh, pulvinar ac pulvinar eu, pulvinar ac enim.</p>

<p>Donec vel velit id elit volutpat vestibulum vitae a erat. Duis id est id magna
aliquam pretium nec sit amet nibh. Nullam condimentum suscipit felis, sed interdum
felis dictum ac. Phasellus non nisi quis magna pellentesque auctor. Cras risus
lectus, viverra eu fringilla malesuada, rhoncus et est. Etiam rhoncus pharetra
accumsan. Nullam suscipit tellus felis.</p>
</section>
<section id="ch2">
<h2>Chapter 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla laoreet nibh felis.
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia
Curae; Etiam est sapien, dapibus eget gravida nec, accumsan a turpis. Nunc in nisi
ut dolor elementum porttitor. Mauris hendrerit pulvinar tincidunt. Etiam metus
metus, ullamcorper ut varius lacinia, luctus et nibh. Donec ut metus enim, id
faucibus nunc. Quisque ut iaculis mauris. Duis pellentesque nulla ut eros ultricies
quis condimentum eros adipiscing. Sed porta ultrices diam, ut sagittis lectus mattis
a. Phasellus gravida, sapien vitae mollis interdum, dui neque tempor arcu, ac ornare
leo ipsum ut nisl.</p>

<p>Donec porta, odio et aliquet molestie, felis tellus fermentum leo, id interdum magna
massa quis ligula. Integer elementum mauris eget nisl eleifend facilisis nec sit
amet tellus. Morbi consectetur dignissim egestas. Donec pulvinar, enim eu auctor
cursus, turpis arcu venenatis turpis, eu cursus magna nisl sit amet ante. Curabitur
eleifend arcu eget nibh facilisis mattis. Etiam nisl nunc, semper vitae condimentum
sed, viverra sit amet lacus. Curabitur et orci augue. Suspendisse sollicitudin
vulputate risus, sit amet consequat erat mollis eu. Nunc sodales tincidunt
tincidunt.</p>

<p>Aliquam erat volutpat. Aliquam ornare augue et nulla consequat commodo. Quisque
dictum rhoncus orci vel euismod. Proin leo turpis, adipiscing quis facilisis id,
condimentum sed metus. Nullam pellentesque scelerisque est nec tristique. Nunc augue
turpis, consequat non varius quis, aliquam auctor dolor. Cras luctus dignissim justo
sit amet laoreet. Quisque vel ipsum quis massa suscipit vehicula.</p>

<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis
egestas. Vivamus fringilla eleifend magna, vel commodo turpis egestas at.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis
egestas. Sed eu lorem quam, et sagittis libero. Maecenas vel ante id sem bibendum
laoreet nec dignissim justo. Class aptent taciti sociosqu ad litora torquent per
conubia nostra, per inceptos himenaeos. Fusce eu lorem orci, eu viverra nisi. Lorem
ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum dapibus commodo
pellentesque. Maecenas quis est accumsan est interdum pharetra egestas nec lorem.
Nam a lectus sit amet justo facilisis suscipit.</p>

<p>Integer dolor dolor, volutpat id commodo id, gravida id risus. Donec consectetur
sollicitudin sem, non auctor urna pulvinar non. Vivamus ipsum nisi, commodo sed
scelerisque id, porta nec massa. Vestibulum ac risus et augue faucibus fermentum ut
et nisi. Integer tincidunt suscipit ipsum, sed interdum felis mollis sed.
Suspendisse potenti. Praesent et mauris et quam consequat tristique. Morbi mi dolor,
pharetra quis rutrum quis, fringilla in tortor. Sed a nulla vitae leo dapibus
cursus. Aliquam erat volutpat. Integer purus purus, dictum id bibendum at, lobortis
quis metus.</p>
</section>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
<rootfiles>
<rootfile full-path="EPUB/lorem.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

0 comments on commit 5a68cc8

Please sign in to comment.