Skip to content

Commit

Permalink
handle IllegalStateException in checkItemContent
Browse files Browse the repository at this point in the history
fixes #666
  • Loading branch information
takahashim authored and tofi86 committed Sep 17, 2017
1 parent 6764e25 commit 2533689
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ static Map<MessageId, Severity> getDefaultSeverities()
map.put(MessageId.CHK_005, Severity.ERROR);
map.put(MessageId.CHK_006, Severity.ERROR);
map.put(MessageId.CHK_007, Severity.ERROR);
map.put(MessageId.CHK_008, Severity.ERROR);

// CSS
map.put(MessageId.CSS_001, Severity.ERROR);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/adobe/epubcheck/messages/MessageId.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public enum MessageId implements Comparable<MessageId>
CHK_005("CHK-005"),
CHK_006("CHK-006"),
CHK_007("CHK-007"),
CHK_008("CHK-008"),

// Messages associated with styles
CSS_001("CSS-001"),
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/com/adobe/epubcheck/opf/OPFChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,15 @@ else if (item.isNav())
}
if (checkerFactory != null)
{
// Create the content checker with an overridden validation context
ContentChecker checker = checkerFactory.newInstance(new ValidationContextBuilder(context)
.path(item.getPath()).mimetype(mimetype).properties(item.getProperties()).build());
// Validate
checker.runChecks();
try {
// Create the content checker with an overridden validation context
ContentChecker checker = checkerFactory.newInstance(new ValidationContextBuilder(context)
.path(item.getPath()).mimetype(mimetype).properties(item.getProperties()).build());
// Validate
checker.runChecks();
} catch (IllegalStateException e) {
report.message(MessageId.CHK_008, EPUBLocation.create(path), item.getPath());
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ CHK_004=The custom message contains too many parameters in message overrides fil
CHK_005=The custom suggestion contains too many parameters in message overrides file '%1$s'.
CHK_006=Unable to parse the custom format parameter in message overrides file '%1$s'.
CHK_007=Error encountered while processing custom message file '%1$s': "%2$s".
CHK_008=Error encountered while processing an item '%1$s'; skip other checkes for the item.

#CSS
CSS_001=The \'%1$s\' property must not be included in an EPUB Style Sheet.
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/com/adobe/epubcheck/api/Epub20CheckTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,12 @@ public void testLinkedStylesheetCaseInsensitiveIssue316() {
Collections.addAll(expectedErrors, MessageId.RSC_007);
testValidateDocument("invalid/issue316.epub");
}

@Test
public void testValidateEPUB_issue21()
{
Collections.addAll(expectedErrors, MessageId.OPF_054, MessageId.OPF_050, MessageId.CHK_008);
Collections.addAll(expectedWarnings, MessageId.OPF_055);
testValidateDocument("/Issue21.epub");
}
}

0 comments on commit 2533689

Please sign in to comment.