diff --git a/README.md b/README.md
index ec929ca..ef2b76c 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,7 @@
# ODF Validator
+Latest version is 0.9.1
+
## About
[Open Preservation Foundation](https://openpreservation.org/)'s OpenDocument Format Validator (OPF ODF Validator) enables your organisation to validate the file format standard and a set of file format policy rules created for improving the preservation effort of any files saved in the OpenDocument Format.
diff --git a/docs/DEVELOPER.md b/docs/DEVELOPER.md
index f8c5822..3ec7744 100644
--- a/docs/DEVELOPER.md
+++ b/docs/DEVELOPER.md
@@ -44,7 +44,7 @@ To include the core validation library in your project, add the following depend
org.openpreservation.odf
odf-core
- 0.9.0
+ 0.9.1
```
diff --git a/odf-apps/pom.xml b/odf-apps/pom.xml
index dcf6a81..7da1f38 100644
--- a/odf-apps/pom.xml
+++ b/odf-apps/pom.xml
@@ -5,7 +5,7 @@
org.openpreservation.odf
odf-validator
- 0.9.0
+ 0.9.1
odf-apps
diff --git a/odf-core/pom.xml b/odf-core/pom.xml
index 7160366..49be51e 100644
--- a/odf-core/pom.xml
+++ b/odf-core/pom.xml
@@ -5,7 +5,7 @@
org.openpreservation.odf
odf-validator
- 0.9.0
+ 0.9.1
org.openpreservation.odf
diff --git a/odf-core/src/main/java/org/openpreservation/odf/pkg/PackageParserImpl.java b/odf-core/src/main/java/org/openpreservation/odf/pkg/PackageParserImpl.java
index e949aca..306a832 100644
--- a/odf-core/src/main/java/org/openpreservation/odf/pkg/PackageParserImpl.java
+++ b/odf-core/src/main/java/org/openpreservation/odf/pkg/PackageParserImpl.java
@@ -77,13 +77,12 @@ private final OdfPackage parsePackage(final Path toParse, final String name) thr
private final OdfPackage makePackage(final String name, final Formats format)
throws ParserConfigurationException, IOException, SAXException {
OdfPackageImpl.Builder builder = OdfPackageImpl.Builder.builder().name(name).archive(this.cache).format(format)
- .mimetype(mimetype)
- .manifest(manifest);
- if (this.manifest == null) {
- return builder.build();
- }
- for (FileEntry docEntry : manifest.getDocumentEntries()) {
- builder.document(docEntry.getFullPath(), makeDocument(docEntry));
+ .mimetype(mimetype);
+ if (this.manifest != null) {
+ builder.manifest(manifest);
+ for (FileEntry docEntry : manifest.getDocumentEntries()) {
+ builder.document(docEntry.getFullPath(), makeDocument(docEntry));
+ }
}
for (Entry docEntry : this.xmlDocumentMap.entrySet()) {
if (isMetaInf(docEntry.getKey())) {
@@ -147,9 +146,11 @@ private final void processEntry(final ZipEntry entry)
OdfXmlDocument xmlDoc = OdfXmlDocuments.xmlDocumentFrom(is);
if (xmlDoc != null) {
this.xmlDocumentMap.put(path, xmlDoc);
+ if (xmlDoc.getParseResult().isWellFormed()) {
+ this.parseOdfXml(path);
+ }
}
}
- this.parseOdfXml(path);
}
private final boolean isOdfXml(final String entrypath) {
diff --git a/odf-core/src/main/java/org/openpreservation/odf/validation/ValidatingParserImpl.java b/odf-core/src/main/java/org/openpreservation/odf/validation/ValidatingParserImpl.java
index 71de7e5..0e6c9b0 100644
--- a/odf-core/src/main/java/org/openpreservation/odf/validation/ValidatingParserImpl.java
+++ b/odf-core/src/main/java/org/openpreservation/odf/validation/ValidatingParserImpl.java
@@ -185,22 +185,24 @@ private final List validateMimeEntry(final ZipEntry mimeEntry, final bo
private List validateManifest(final OdfPackage odfPackage) {
final List messages = new ArrayList<>();
Manifest manifest = odfPackage.getManifest();
- if (manifest.getEntry("/") == null) {
+ if (manifest != null && manifest.getEntry("/") == null) {
if (!odfPackage.hasMimeEntry()) {
messages.add(FACTORY.getWarning("PKG-19"));
} else {
messages.add(FACTORY.getError("PKG-11"));
}
- } else if (!hasManifestRootMime(manifest) || (odfPackage.hasMimeEntry()
+ } else if (hasManifestRootMime(manifest) && (odfPackage.hasMimeEntry()
&& !manifest.getRootMediaType().equals(odfPackage.getMimeType()))) {
messages.add(FACTORY.getError("PKG-12", manifest.getRootMediaType(), odfPackage.getMimeType()));
}
- messages.addAll(checkManifestEntries(odfPackage));
+ if (manifest != null) {
+ messages.addAll(checkManifestEntries(odfPackage));
+ }
return messages;
}
private boolean hasManifestRootMime(final Manifest manifest) {
- return manifest.getRootMediaType() != null;
+ return manifest != null && manifest.getRootMediaType() != null;
}
private List checkManifestEntries(final OdfPackage odfPackage) {
diff --git a/odf-core/src/test/java/org/openpreservation/odf/fmt/TestFiles.java b/odf-core/src/test/java/org/openpreservation/odf/fmt/TestFiles.java
index 240b8ec..5102266 100644
--- a/odf-core/src/test/java/org/openpreservation/odf/fmt/TestFiles.java
+++ b/odf-core/src/test/java/org/openpreservation/odf/fmt/TestFiles.java
@@ -13,6 +13,7 @@ public class TestFiles {
final static String EMBEDDED_TEST_ROOT = PKG_TEST_ROOT + "embedded/";
final static String ENCRYPTED_TEST_ROOT = PKG_TEST_ROOT + "encrypted/";
final static String DSIG_TEST_ROOT = PKG_TEST_ROOT + "dsigs/";
+ final static String INVALID_PKG_ROOT = PKG_TEST_ROOT + "invalid/";
final static String XML_TEST_ROOT = TEST_ROOT + "xml/";
final static String FILE_TEST_ROOT = TEST_ROOT + "files/";
public final static URL EMPTY_ODS = ClassLoader.getSystemResource(ZIP_TEST_ROOT + "empty.ods");
@@ -56,4 +57,5 @@ public class TestFiles {
public final static URL DSIG_INVALID = ClassLoader.getSystemResource(DSIG_TEST_ROOT + "dsigs.odt");
public final static URL DSIG_VALID = ClassLoader.getSystemResource(DSIG_TEST_ROOT + "dsigs-valid.ods");
public final static URL DSIG_BADNAME = ClassLoader.getSystemResource(DSIG_TEST_ROOT + "bad_dsig_name.ods");
+ public final static URL MANIFEST_NOT_WF = ClassLoader.getSystemResource(INVALID_PKG_ROOT + "manifest_not_wf.ods");
}
diff --git a/odf-core/src/test/java/org/openpreservation/odf/pkg/PackageParserTest.java b/odf-core/src/test/java/org/openpreservation/odf/pkg/PackageParserTest.java
index 45111d9..657eb1a 100644
--- a/odf-core/src/test/java/org/openpreservation/odf/pkg/PackageParserTest.java
+++ b/odf-core/src/test/java/org/openpreservation/odf/pkg/PackageParserTest.java
@@ -1,6 +1,7 @@
package org.openpreservation.odf.pkg;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
@@ -103,4 +104,14 @@ public void testDsigParsing() throws ParserConfigurationException, SAXException,
assertNotNull("Dsig file META-INF/documentsignatures.xml result should not be null" , result);
assertTrue("Package should have a well formed dsig for META-INF/documentsignatures.xml" , result.isWellFormed());
}
+
+ @Test
+ public void testManifestNotWF() throws IOException {
+ PackageParser parser = OdfPackages.getPackageParser();
+ InputStream is = TestFiles.MANIFEST_NOT_WF.openStream();
+ OdfPackage pkg = parser.parsePackage(is, TestFiles.MANIFEST_NOT_WF.toString());
+ ParseResult result = pkg.getEntryXmlParseResult("META-INF/manifest.xml");
+ assertNotNull("Dsig file META-INF/documentsignatures.xml result should not be null" , result);
+ assertFalse("Package should NOT have a well formed META-INF/manifest.xml" , result.isWellFormed());
+ }
}
diff --git a/odf-core/src/test/resources/org/openpreservation/odf/fmt/pkg/invalid/manifest_not_wf.ods b/odf-core/src/test/resources/org/openpreservation/odf/fmt/pkg/invalid/manifest_not_wf.ods
new file mode 100644
index 0000000..a97b702
Binary files /dev/null and b/odf-core/src/test/resources/org/openpreservation/odf/fmt/pkg/invalid/manifest_not_wf.ods differ
diff --git a/pom.xml b/pom.xml
index d68ae3b..9879665 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
org.openpreservation.odf
odf-validator
- 0.9.0
+ 0.9.1
pom