Skip to content

Commit 6764e25

Browse files
takahashimtofi86
authored andcommitted
Check MimeType uncompressed (PR #784, fixes #303)
* check mimetype file should not be compressed (PKG_007) * test removed because test against 'lorem-mimetype' is already in Epub30CheckExpandedTest see testValidateEPUBPLoremMimetype() in src/test/java/com/adobe/epubcheck/api/Epub30CheckExpandedTest.java
1 parent c1808ac commit 6764e25

File tree

3 files changed

+8
-19
lines changed

3 files changed

+8
-19
lines changed

src/main/java/com/adobe/epubcheck/api/EpubCheck.java

+4
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ else if (!CheckUtil.checkString(header, 30, "mimetype"))
308308
{
309309
report.message(MessageId.PKG_006, EPUBLocation.create(epubFile.getName()));
310310
}
311+
else if (!CheckUtil.checkString(header, 38, "application/epub+zip"))
312+
{
313+
report.message(MessageId.PKG_007, EPUBLocation.create("mimetype"));
314+
}
311315
}
312316
}
313317

src/main/java/com/adobe/epubcheck/util/CheckUtil.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,16 @@ public static boolean checkTrailingSpaces(InputStream input,
6969
{
7070
if ((c = input.read()) == -1)
7171
{
72-
return false;
72+
return true; // ignored; should be checked by checkEpubHeader() in com.adobe.epubcheck.api.EpubCheck
7373
}
7474
else
7575
{
7676
baos.write(c);
7777
}
7878
}
79+
if (! baos.toString().equals("application/epub+zip")) {
80+
return true; // ignored; should be checked by checkEpubHeader() in com.adobe.epubcheck.api.EpubCheck
81+
}
7982

8083
int ch = input.read();
8184
if (version == EPUBVersion.VERSION_2 && ch != -1)

src/test/java/com/adobe/epubcheck/ocf/OCFCheckerTest.java

-18
Original file line numberDiff line numberDiff line change
@@ -393,24 +393,6 @@ public void testInvalidLoremForeign30()
393393
assertTrue(testReport.hasInfoMessage("[format version] 3.0.1"));
394394
}
395395

396-
@Test
397-
public void testInvalidLoremMimetype30()
398-
{
399-
ValidationReport testReport = testOcfPackage("/30/expanded/invalid/lorem-mimetype/",
400-
EPUBVersion.VERSION_3);
401-
if (1 != testReport.getErrorCount() || 0 != testReport.getWarningCount())
402-
{
403-
outWriter.println(testReport);
404-
}
405-
406-
List<MessageId> errors = new ArrayList<MessageId>();
407-
Collections.addAll(errors, MessageId.PKG_007);
408-
assertEquals(errors, testReport.getErrorIds());
409-
assertEquals(0, testReport.getWarningCount());
410-
411-
assertTrue(testReport.hasInfoMessage("[format version] 3.0.1"));
412-
}
413-
414396
@Test
415397
public void testInvalidLoremPoster30()
416398
{

0 commit comments

Comments
 (0)