You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2009/09/01 19:00:16 UTC
svn commit: r810122 -
/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
Author: lehmi
Date: Tue Sep 1 17:00:16 2009
New Revision: 810122
URL: http://svn.apache.org/viewvc?rev=810122&view=rev
Log:
PDFBOX-471: make the BaseParser more lenient concerning bad dictionaries. Patch from Sean Bridges (sean dot bridges at gmail dot com)
Modified:
incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
Modified: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java?rev=810122&r1=810121&r2=810122&view=diff
==============================================================================
--- incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java (original)
+++ incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/BaseParser.java Tue Sep 1 17:00:16 2009
@@ -183,7 +183,23 @@
if( c == '>')
{
done = true;
- }
+ }
+ else
+ if(c != '/')
+ {
+ //an invalid dictionary, we are expecting
+ //the key, read until we can recover
+ logger().warning("Invalid dictionary, found:" + (char)c + " but expected:\''");
+ int read = pdfSource.read();
+ while(read != -1 && read != '/' && read != '>')
+ {
+ read = pdfSource.read();
+ }
+ if(read != -1)
+ {
+ pdfSource.unread(read);
+ }
+ }
else
{
COSName key = parseCOSName();
@@ -206,9 +222,12 @@
if( value == null )
{
- throw new IOException("Bad Dictionary Declaration " + pdfSource );
+ logger().warning("Bad Dictionary Declaration " + pdfSource );
+ }
+ else
+ {
+ obj.setItem( key, value );
}
- obj.setItem( key, value );
}
}
char ch = (char)pdfSource.read();