If you have a look at https://bugs.freedesktop.org/show_bug.cgi?id=14337 
you'll find a PDF that has a name of more than 127 characters, that is the 
most we parse because it's an "Implementation limit" as specified in Appendix 
C of the specification.

Although, if you open the said file with acroread, it works.

So i suggest to apply the following patch effectively doubling the max 
characters we accept as name length.

Comments?

Albert
diff --git a/poppler/Lexer.cc b/poppler/Lexer.cc
index 270c135..85396de 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,27 @@ Object *Lexer::getObj(Object *obj, int objNum) {
 	}
       }
      notEscChar:
-      if (++n == tokBufSize) {
-	error(getPos(), "Name token too long");
-	break;
+      if (n == tokBufSize) {
+	if (!s)
+	  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
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to