You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2018/09/03 18:40:07 UTC

svn commit: r1839981 - /pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java

Author: tilman
Date: Mon Sep  3 18:40:07 2018
New Revision: 1839981

URL: http://svn.apache.org/viewvc?rev=1839981&view=rev
Log:
PDFBOX-4308: add test

Modified:
    pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java

Modified: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java?rev=1839981&r1=1839980&r2=1839981&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/encryption/TestSymmetricKeyEncryption.java Mon Sep  3 18:40:07 2018
@@ -210,6 +210,27 @@ public class TestSymmetricKeyEncryption
     }
 
     /**
+     * PDFBOX-4308: test that index colorspace table string doesn't get
+     * corrupted when encrypting. This happened because the table was used by
+     * two dictionaries, and when saving one string ended up as a direct object
+     * and the other (but same java object) ended up as an indirect object.
+     * Encryption used the wrong object number and/or the object was encrypted
+     * twice.
+     *
+     * @throws IOException
+     */
+    public void testPDFBox4308() throws IOException
+    {
+        InputStream is = new FileInputStream("target/pdfs/PDFBOX-4308.pdf");
+        byte[] inputFileAsByteArray = IOUtils.toByteArray(is);
+        is.close();
+        int sizePriorToEncryption = inputFileAsByteArray.length;
+
+        testSymmEncrForKeySize(40, false, sizePriorToEncryption, inputFileAsByteArray,
+                USERPASSWORD, OWNERPASSWORD, permission);
+    }
+
+    /**
      * Protect a document with an embedded PDF with a key and try to reopen it
      * with that key and compare.
      *