You are viewing a plain text version of this content. The canonical link for it is here.
Posted to odf-commits@incubator.apache.org by ms...@apache.org on 2018/05/14 13:13:46 UTC

[odftoolkit] 01/02: ODFTOOLKIT-460 validator: do not report missing file entries for document signatures

This is an automated email from the ASF dual-hosted git repository.

mst pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/odftoolkit.git

commit 655fd67275f116ee42f3856e9428766073e59187
Author: Michael Stahl <ms...@redhat.com>
AuthorDate: Tue Jul 18 17:52:30 2017 +0200

    ODFTOOLKIT-460 validator: do not report missing file entries for document signatures
    
    ODF 1.2, part3, 3.2 Manifest:
    
    The “META-INF/manifest.xml” file need not contain <manifest:file-entry>
    elements 4.3 whose manifest:full-path attribute 4.8.4 references files
    whose relative path start with "META-INF/".
---
 .../java/org/odftoolkit/odfdom/pkg/OdfPackage.java    |   5 ++++-
 .../odftoolkit/odfvalidator/InvalidPackageTest.java   |  18 ++++++++++++++++++
 validator/src/test/resources/good.odt                 | Bin 0 -> 10878 bytes
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfPackage.java b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfPackage.java
index 82d8dc9..29a998f 100644
--- a/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfPackage.java
+++ b/odfdom/src/main/java/org/odftoolkit/odfdom/pkg/OdfPackage.java
@@ -502,7 +502,10 @@ public class OdfPackage implements Closeable {
 			String internalPath;
 			while (iter.hasNext()) {
 				internalPath = (String) iter.next();
-				if (!internalPath.endsWith(SLASH)) { // not for directories!
+				if (!internalPath.endsWith(SLASH) && // not for directories!
+					// The “META-INF/manifest.xml” file need not contain <manifest:file-entry> elements 4.3 whose manifest:full-path attribute 4.8.4 references files whose relative path start with "META-INF/".
+					!internalPath.startsWith("META-INF/"))
+				{
 					logValidationError(OdfPackageConstraint.MANIFEST_DOES_NOT_LIST_FILE, documentURL, internalPath);
 				}
 			}
diff --git a/validator/src/test/java/org/odftoolkit/odfvalidator/InvalidPackageTest.java b/validator/src/test/java/org/odftoolkit/odfvalidator/InvalidPackageTest.java
index b9e1b66..de75465 100644
--- a/validator/src/test/java/org/odftoolkit/odfvalidator/InvalidPackageTest.java
+++ b/validator/src/test/java/org/odftoolkit/odfvalidator/InvalidPackageTest.java
@@ -127,4 +127,22 @@ public class InvalidPackageTest extends OdfValidatorTestBase {
         Assert.assertTrue(output.contains("Fatal: ZIP entry 'mimetype': only DEFLATED entries can have EXT descriptor"));
         java.util.logging.Logger.getLogger(getClass().getName()).log(Level.INFO, "Test result:\n{0}", output);
     }
+
+    @Test
+    public void validateDocumentSignature() {
+        String output = "";
+        try {
+            // the manifest.xml is valid, but "META-INF/documentsignatures.xml"
+            // was erroneously reported as missing
+            String name = "good.odt";
+            output = doValidation(name, OdfVersion.V1_2, OdfValidatorMode.EXTENDED_CONFORMANCE);
+        } catch (Throwable t) {
+            t.printStackTrace();
+            Assert.fail(t.toString());
+        }
+        Assert.assertFalse("Output of validateDocumentSignature(): " + output, output.contains("Error: The file 'META-INF/documentsignatures.xml' shall be listed in the 'META-INF/manifest.xml' file as it exists in the ODF package 'good.odt'"));
+        Assert.assertTrue("Output of validateDocumentSignature(): " + output, output.contains("Error: element \"document-signatures\" is missing \"version\" attribute"));
+        Assert.assertTrue("Output of validateDocumentSignature(): " + output, output.contains("good.odt:  Info: 1 errors, no warnings"));
+    }
+
 }
diff --git a/validator/src/test/resources/good.odt b/validator/src/test/resources/good.odt
new file mode 100644
index 0000000..8c6019d
Binary files /dev/null and b/validator/src/test/resources/good.odt differ

-- 
To stop receiving notification emails like this one, please contact
mst@apache.org.