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 2014/09/27 21:36:40 UTC

svn commit: r1627990 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java

Author: tilman
Date: Sat Sep 27 19:36:40 2014
New Revision: 1627990

URL: http://svn.apache.org/r1627990
Log:
PDFBOX-2376: improve recognition of token after EI

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java?rev=1627990&r1=1627989&r2=1627990&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/PDFStreamParser.java Sat Sep 27 19:36:40 2014
@@ -467,28 +467,24 @@ public class PDFStreamParser extends Bas
                     break;
                 }
                 // find the start of a PDF operator
-                if (startOpIdx == -1 && (b == 9 || b == 0x20 || b == 0x0a || b == 0x0d))
+                if (startOpIdx == -1 && !(b == 9 || b == 0x20 || b == 0x0a || b == 0x0d))
                 {
                     startOpIdx = bIdx;
                 }
                 else if (startOpIdx != -1 && endOpIdx == -1 &&
                          (b == 9 || b == 0x20 || b == 0x0a || b == 0x0d))
                 {
-                    if (bIdx == startOpIdx + 1)
-                    {
-                        // several blanks after another
-                        startOpIdx = bIdx;
-                    }
-                    else
-                    {
-                        endOpIdx = bIdx;
-                    }
+                    endOpIdx = bIdx;
                 }
             }
             if (readBytes == MAX_BIN_CHAR_TEST_LENGTH) // only if not close to eof
             {
                 // a PDF operator is 1-3 bytes long
-                if (endOpIdx == -1 || startOpIdx == -1 || endOpIdx - startOpIdx > 3)
+                if (startOpIdx != -1 && endOpIdx == -1)
+                {
+                    endOpIdx = MAX_BIN_CHAR_TEST_LENGTH;
+                }
+                if (endOpIdx != -1 && startOpIdx != -1 && endOpIdx - startOpIdx > 3)
                 {
                     noBinData = false;
                 }