[poppler] Branch 'poppler-0.6' - poppler/Lexer.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Thu Feb 7 14:39:50 PST 2008


 poppler/Lexer.cc |   25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

New commits:
commit 3aa535119181fc51aee1f2c1786e9fa4e35ea0a7
Author: Albert Astals Cid <aacid at kde.org>
Date:   Thu Feb 7 23:38:50 2008 +0100

    PDF spec says name tokens have a maximum length of 127, but there are some docs in the wild with more than that and they work on acroread so increase the allowed length to 128+127

diff --git a/poppler/Lexer.cc b/poppler/Lexer.cc
index 270c135..09a3f13 100644
--- a/poppler/Lexer.cc
+++ b/poppler/Lexer.cc
@@ -348,6 +348,7 @@ Object *Lexer::getObj(Object *obj, int objNum) {
   case '/':
     p = tokBuf;
     n = 0;
+    s = NULL;
     while ((c = lookChar()) != EOF && !specialChars[c]) {
       getChar();
       if (c == '#') {
@@ -375,14 +376,30 @@ Object *Lexer::getObj(Object *obj, int objNum) {
 	}
       }
      notEscChar:
-      if (++n == tokBufSize) {
-	error(getPos(), "Name token too long");
-	break;
+      if (n == tokBufSize) {
+	if (!s)
+	{
+	  error(getPos(), "Warning: name token is longer than what the specification says it can be");
+	  s = new GooString(tokBuf, tokBufSize);
+	}
+	else
+	{
+	  // the spec says 127 is the maximum, we are already at 256 so bail out
+	  error(getPos(), "Name token too long");
+	  break;
+	}
+	p = tokBuf;
+	n = 0;
       }
       *p++ = c;
+      ++n;
     }
     *p = '\0';
-    obj->initName(tokBuf);
+    if (s) {
+      s->append(tokBuf, n);
+      obj->initName(s->getCString());
+      delete s;
+    } else obj->initName(tokBuf);
     break;
 
   // array punctuation


More information about the poppler mailing list