pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1826836 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox: cos/COSObjectKey.java pdfparser/COSParser.java
Date Thu, 15 Mar 2018 17:34:54 GMT
Author: lehmi
Date: Thu Mar 15 17:34:53 2018
New Revision: 1826836

URL: http://svn.apache.org/viewvc?rev=1826836&view=rev
Log:
PDFBOX-4153: fix incremented generation number of an objectkey

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObjectKey.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObjectKey.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObjectKey.java?rev=1826836&r1=1826835&r2=1826836&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObjectKey.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSObjectKey.java Thu Mar 15 17:34:53
2018
@@ -25,7 +25,7 @@ package org.apache.pdfbox.cos;
 public class COSObjectKey implements Comparable<COSObjectKey>
 {
     private final long number;
-    private final int generation;
+    private int generation;
     
     /**
      * PDFObjectKey constructor comment.
@@ -70,6 +70,17 @@ public class COSObjectKey implements Com
     {
         return generation;
     }
+
+    /**
+     * This will set the generation number. It is intended for fixes only.
+     * 
+     * @param genNumber the new generation number.
+     */
+    public void fixGeneration(int genNumber)
+    {
+        generation = genNumber;
+    }
+
     /**
      * This will get the objects id.
      *

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java?rev=1826836&r1=1826835&r2=1826836&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java Thu Mar 15
17:34:53 2018
@@ -1417,14 +1417,19 @@ public class COSParser extends BaseParse
             if (objectKey.getNumber() == readObjectNumber())
             {
                 int genNumber = readGenerationNumber();
-                //
-                if (genNumber == objectKey.getGeneration()
-                        || (isLenient && genNumber > objectKey.getGeneration()))
+                if (genNumber == objectKey.getGeneration())
                 {
                     // finally try to read the object marker
                     readExpectedString(OBJ_MARKER, true);
                     objectKeyFound = true;
                 }
+                else if (isLenient && genNumber > objectKey.getGeneration())
+                {
+                    // finally try to read the object marker
+                    readExpectedString(OBJ_MARKER, true);
+                    objectKeyFound = true;
+                    objectKey.fixGeneration(genNumber);
+                }
             }
         }
         catch (IOException exception)



Mime
View raw message