Skip to content

Commit

Permalink
fix: report fatal XML parsing errors only once as RSC-016
Browse files Browse the repository at this point in the history
  • Loading branch information
rdeltour committed Nov 14, 2022
1 parent 6a58b8e commit 62d67e7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/main/java/com/adobe/epubcheck/xml/XMLParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ public void process()
report.message(MessageId.PKG_008, EPUBLocation.of(context), context.path);
} catch (SAXException e)
{
report.message(MessageId.RSC_005, EPUBLocation.of(context), e.getMessage());
// All errors should have already been reported by the error handler
if (report.getFatalErrorCount() == 0) {
report.message(MessageId.RSC_016, EPUBLocation.of(context), e.getMessage());
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/test/java/com/adobe/epubcheck/ocf/OPFPeekerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,16 @@ public void testRetrieveVersionNoVersionAttribute()
@Test
public void testRetrieveVersionNoEqualSign()
{
Collections.addAll(expectedErrors, MessageId.RSC_005, MessageId.RSC_005);
Collections.addAll(expectedErrors, MessageId.RSC_005);
Collections.addAll(expectedFatals, MessageId.RSC_016);
retrieveData("noEqual.opf");
}

@Test
public void testRetrieveVersionValueWithoutQuotes()
{
Collections.addAll(expectedErrors, MessageId.RSC_005, MessageId.RSC_005);
Collections.addAll(expectedErrors, MessageId.RSC_005);
Collections.addAll(expectedFatals, MessageId.RSC_016);
retrieveData("valueWithoutQuotes.opf");
}

Expand Down
2 changes: 0 additions & 2 deletions src/test/resources/epub3/03-resources/resources.feature
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,12 @@
Scenario: a not well-formed Package Document is reported
When checking file 'conformance-xml-malformed-error.opf'
Then fatal error RSC-016 is reported (parsing error)
And error RSC-005 is reported (schema error)
And no other errors or warnings are reported

@spec @xref:sec-xml-constraint
Scenario: using a not-declared namespace is not allowed
When checking file 'conformance-xml-undeclared-namespace-error.opf'
Then fatal error RSC-016 is reported (parsing error)
And error RSC-005 is reported (schema error)
And no other errors or warnings are reported

Scenario: Verify an attribute value with leading/trailing whitespace is allowed (issue 332)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,12 @@ Feature: EPUB 3 — Content Documents — XHTML
Scenario: Report entity references not ending with a semicolon
When checking document 'entities-no-semicolon-error.xhtml'
Then fatal error RSC-016 is reported
And error RSC-005 is reported
And the message contains 'must end with the \';\' delimiter'
And no other errors or warnings are reported

Scenario: Report unknown entity references
When checking document 'entities-unknown-error.xhtml'
Then fatal error RSC-016 is reported
And error RSC-005 is reported
And the message contains 'was referenced, but not declared'
And no other errors or warnings are reported

Expand Down

0 comments on commit 62d67e7

Please sign in to comment.