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 2022/04/17 13:02:30 UTC
svn commit: r1899943 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
Author: lehmi
Date: Sun Apr 17 13:02:30 2022
New Revision: 1899943
URL: http://svn.apache.org/viewvc?rev=1899943&view=rev
Log:
PDFBOX-5419: skip unexpected whitespaces
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java?rev=1899943&r1=1899942&r2=1899943&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java Sun Apr 17 13:02:30 2022
@@ -1554,38 +1554,42 @@ public class COSParser extends BaseParse
}
try
{
- source.seek(offset - 1);
+ source.seek(offset);
skipWhiteSpaces();
- // ensure that at least one whitespace is skipped in front of the object number
- if (source.getPosition() < offset)
+ if (source.getPosition() == offset)
{
- if (!isDigit())
+ // ensure that at least one whitespace is skipped in front of the object number
+ source.seek(offset - 1);
+ if (source.getPosition() < offset)
{
- // anything else but a digit may be some garbage of the previous object -> just ignore it
- source.read();
- }
- else
- {
- long current = source.getPosition();
- source.seek(--current);
- while (isDigit())
- source.seek(--current);
- long newObjNr = readObjectNumber();
- int newGenNr = readGenerationNumber();
- COSObjectKey newObjKey = new COSObjectKey(newObjNr, newGenNr);
- Long existingOffset = xrefOffset.get(newObjKey);
- // the found object number belongs to another uncompressed object at the same or nearby offset
- // something has to be wrong
- if (existingOffset != null && existingOffset > 0
- && Math.abs(offset - existingOffset) < 10)
+ if (!isDigit())
{
- LOG.debug("Found the object " + newObjKey + " instead of " //
- + objectKey + " at offset " + offset //
- + " - ignoring");
- return null;
+ // anything else but a digit may be some garbage of the previous object -> just ignore it
+ source.read();
+ }
+ else
+ {
+ long current = source.getPosition();
+ source.seek(--current);
+ while (isDigit())
+ source.seek(--current);
+ long newObjNr = readObjectNumber();
+ int newGenNr = readGenerationNumber();
+ COSObjectKey newObjKey = new COSObjectKey(newObjNr, newGenNr);
+ Long existingOffset = xrefOffset.get(newObjKey);
+ // the found object number belongs to another uncompressed object at the same or nearby offset
+ // something has to be wrong
+ if (existingOffset != null && existingOffset > 0
+ && Math.abs(offset - existingOffset) < 10)
+ {
+ LOG.debug("Found the object " + newObjKey + " instead of " //
+ + objectKey + " at offset " + offset //
+ + " - ignoring");
+ return null;
+ }
+ // something seems to be wrong but it's hard to determine what exactly -> simply continue
+ source.seek(offset);
}
- // something seems to be wrong but it's hard to determine what exactly -> simply continue
- source.seek(offset);
}
}
// try to read the given object/generation number