Skip to content

Commit

Permalink
FIX: Crashing policy macro check of unreadable entries. (#206)
Browse files Browse the repository at this point in the history
- null stream entries are no longer checked for macros.
  • Loading branch information
carlwilson authored Oct 29, 2024
1 parent 00da92f commit 138c8e6
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.openpreservation.odf.validation.rules;

import java.io.IOException;
import java.io.InputStream;

import javax.xml.parsers.ParserConfigurationException;

Expand Down Expand Up @@ -60,11 +61,16 @@ private MessageLog checkOdfScriptXml(final OdfPackage odfPackage) throws IOExcep
throw new IllegalStateException(e);
}
for (FileEntry entry : odfPackage.getXmlEntries()) {
ParseResult result = checker.parse(odfPackage.getEntryStream(entry));
if (NS_SCRIPTS.equals(result.getRootNamespace().getId().toASCIIString())
&& "module".equals(result.getRootName())) {
messageLog.add(entry.getFullPath(), Messages.getMessageInstance(id, severity, name, description));
try (final InputStream entryStream = odfPackage.getEntryStream(entry)) {
if (entryStream == null) {
continue;
}
ParseResult result = checker.parse(odfPackage.getEntryStream(entry));
if (NS_SCRIPTS.equals(result.getRootNamespace().getId().toASCIIString())
&& "module".equals(result.getRootName())) {
messageLog.add(entry.getFullPath(), Messages.getMessageInstance(id, severity, name, description));

}
}
}
return messageLog;
Expand Down

0 comments on commit 138c8e6

Please sign in to comment.