Skip to content

Commit

Permalink
FIX: Validation of meta-inf files (#218)
Browse files Browse the repository at this point in the history
- validation driven by manifest failed to validate `META-INF/*` files.
  • Loading branch information
carlwilson authored Nov 1, 2024
1 parent ea0133f commit 96fc79b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ public interface OpenDocument {
public Collection<OdfDocument> getSubDocuments();

/**
* Get the ODF Package for the OpenDocument, this will be null for a single XML file.
* Get the ODF Package for the OpenDocument, this will be null for a single XML
* file.
*
* @return the ODF Package for the OpenDocument
*/
public OdfPackage getPackage();

/**
* Get the format of the OpenDocument, this will be the declared format of the package
* Get the format of the OpenDocument, this will be the declared format of the
* package
* or the parsed format of a single document.
*
* @return the format of the OpenDocument
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ private final Map<String, List<Message>> validateOdfXmlEntries(final OdfPackage
for (final FileEntry xmlEntry : odfPackage.getXmlEntries()) {
messages.put(xmlEntry.getFullPath(), validateXmlEntry(xmlEntry, odfPackage));
}
for (final Entry<String, ParseResult> entry : odfPackage.getMetaInfMap().entrySet()) {
messages.put(entry.getKey(), validatePackageXml(entry.getKey(), odfPackage, entry.getValue()));
}
return messages;
}

Expand All @@ -119,7 +122,12 @@ private final List<Message> validateXmlEntry(final FileEntry xmlEntry, final Odf
if (xmlEntry.isEncrypted()) {
return Arrays.asList(FACTORY.getWarning("PKG-10", xmlPath));
}
ParseResult parseResult = odfPackage.getEntryXmlParseResult(xmlPath);
return validatePackageXml(xmlPath, odfPackage, odfPackage.getEntryXmlParseResult(xmlPath));

}

private final List<Message> validatePackageXml(final String xmlPath, final OdfPackage odfPackage,
final ParseResult parseResult) {
if (parseResult == null) {
return new ArrayList<>();
}
Expand Down

0 comments on commit 96fc79b

Please sign in to comment.