pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1625736 - /pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java
Date Wed, 17 Sep 2014 18:43:26 GMT
Author: tilman
Date: Wed Sep 17 18:43:25 2014
New Revision: 1625736

URL: http://svn.apache.org/r1625736
Log:
PDFBOX-2306: be lenient, allow stream to end with endobj

Modified:
    pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java

Modified: pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java?rev=1625736&r1=1625735&r2=1625736&view=diff
==============================================================================
--- pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java
(original)
+++ pdfbox/branches/1.8/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/NonSequentialPDFParser.java
Wed Sep 17 18:43:25 2014
@@ -1619,9 +1619,17 @@ public class NonSequentialPDFParser exte
                 readUntilEndStream(new EndstreamOutputStream(out));
             }
             String endStream = readString();
-            if (!endStream.equals("endstream"))
+            if (endStream.equals("endobj") && isLenient)
             {
-                throw new IOException("Error reading stream using length value. Expected='endstream'
actual='"
+                LOG.warn("stream ends with 'endobj' instead of 'endstream' at offset "
+                        + pdfSource.getOffset());
+                // avoid follow-up warning about missing endobj
+                pdfSource.unread("endobj".getBytes("ISO-8859-1"));
+            }
+            else if (!endStream.equals("endstream"))
+            {
+                throw new IOException(
+                        "Error reading stream, expected='endstream' actual='"
                         + endStream + "' at offset " + pdfSource.getOffset());
             }
         }



Mime
View raw message