Skip to content

Commit

Permalink
fix: check trailing spaces in mimetype file
Browse files Browse the repository at this point in the history
  • Loading branch information
rdeltour committed Apr 5, 2019
1 parent 8a1b650 commit 123c69f
Show file tree
Hide file tree
Showing 138 changed files with 295 additions and 120 deletions.
7 changes: 1 addition & 6 deletions src/main/java/com/adobe/epubcheck/util/CheckUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,7 @@ public static boolean checkTrailingSpaces(InputStream input,
}

int ch = input.read();
if (version == EPUBVersion.VERSION_2 && ch != -1)
{
return false;
}

if (version == EPUBVersion.VERSION_3 && ch != ' ' && ch != -1)
if (ch != -1)
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,32 @@ public void testValidateEPUBPLoremBasicMathml()
}

@Test
public void testValidateEPUBPLoremMimetype()
public void testMimetypeHasCorrectValue()
{
Collections.addAll(expectedErrors, MessageId.PKG_007);
testValidateDocument("invalid/mimetype-file-incorrect-value");
}

@Test
public void testMimetypeHasNoLeadingSpaces()
{
Collections.addAll(expectedErrors, MessageId.PKG_007);
testValidateDocument("invalid/mimetype-file-leading-spaces");
}

@Test
public void testMimetypeHasNoTrailingNewline()
{
Collections.addAll(expectedErrors, MessageId.PKG_007);
testValidateDocument("invalid/mimetype-file-trailing-newline");
}

@Test
public void testMimetypeHasNoTrailingSpaces()
{
Collections.addAll(expectedErrors, MessageId.PKG_007);
testValidateDocument("invalid/mimetype-file-trailing-spaces");
}

@Test
public void testValidateEPUBPLoremLink()
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/adobe/epubcheck/api/Epub30CheckTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public void testDuplicateZipEntriesIssue265()
{
// duplicate entries should raise an error
Collections.addAll(expectedErrors, MessageId.OPF_060);
testValidateDocument("invalid/issue265.epub");
testValidateDocument("invalid/zip-duplicate-entry.epub");
}

@Test
Expand All @@ -243,7 +243,7 @@ public void testDuplicateZipEntriesIssue265c()
public void testExtendedFieldofZip()
{
Collections.addAll(expectedErrors, MessageId.PKG_005);
testValidateDocument("invalid/lorem-zip64.epub");
testValidateDocument("invalid/zip-extra-field.epub");
}

@Test
Expand Down
Binary file not shown.
Binary file removed src/test/resources/30/epub/invalid/issue265.epub
Binary file not shown.
Binary file modified src/test/resources/30/epub/invalid/issue265b.epub
Binary file not shown.
Binary file modified src/test/resources/30/epub/invalid/issue265c.epub
Binary file not shown.
Binary file removed src/test/resources/30/epub/invalid/lorem-zip64.epub
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
2 changes: 1 addition & 1 deletion src/test/resources/30/expanded/invalid/issue189/mimetype
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
Original file line number Diff line number Diff line change
@@ -1 +1 @@
application/epub+zip
application/epub+zip
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="OPS/package.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
<head>
<title>Minimal EPUB</title>
</head>
<body epub:type="bodymatter">
<h1>Loomings</h1>
<p>Call me Ishmael.</p>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
<head>
<title>Minimal Nav</title>
</head>
<body>
<nav epub:type="toc">
<ol>
<li><a href="content_001.xhtml">content 001</a></li>
</ol>
</nav>
<nav epub:type="landmarks">
<ol>
<li><a href="content_001.xhtml" epub:type="bodymatter">Start Reading</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 @@
application/epub+zip
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="OPS/package.opf" media-type="application/oebps-package+xml"/>
</rootfiles>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
<head>
<title>Minimal EPUB</title>
</head>
<body epub:type="bodymatter">
<h1>Loomings</h1>
<p>Call me Ishmael.</p>
</body>
</html>
Loading

0 comments on commit 123c69f

Please sign in to comment.