Skip to content

Commit e30b51d

Browse files
committed
PDFBOX-5660: simplify code, as suggested by Valery Bokov; closes #329
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1929684 13f79535-47bb-0310-9956-ffa450edef68
1 parent 52dea1f commit e30b51d

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

pdfbox/src/main/java/org/apache/pdfbox/pdfparser/BruteForceParser.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -417,23 +417,17 @@ private boolean bfSearchForTrailer(COSDictionary trailer) throws IOException
417417
{
418418
trailer.setItem(COSName.ROOT, rootObj);
419419
trailer.setItem(COSName.INFO, infoObj);
420-
if (trailerDict.containsKey(COSName.ENCRYPT))
420+
COSObject encObj = trailerDict.getCOSObject(COSName.ENCRYPT);
421+
// check if the dictionary can be dereferenced
422+
// TODO check if the dictionary is an encryption dictionary?
423+
if (encObj != null && encObj.getObject() instanceof COSDictionary)
421424
{
422-
COSObject encObj = trailerDict.getCOSObject(COSName.ENCRYPT);
423-
// check if the dictionary can be dereferenced
424-
// TODO check if the dictionary is an encryption dictionary?
425-
if (encObj != null && encObj.getObject() instanceof COSDictionary)
426-
{
427-
trailer.setItem(COSName.ENCRYPT, encObj);
428-
}
425+
trailer.setItem(COSName.ENCRYPT, encObj);
429426
}
430-
if (trailerDict.containsKey(COSName.ID))
427+
COSBase idObj = trailerDict.getItem(COSName.ID);
428+
if (idObj instanceof COSArray)
431429
{
432-
COSBase idObj = trailerDict.getItem(COSName.ID);
433-
if (idObj instanceof COSArray)
434-
{
435-
trailer.setItem(COSName.ID, idObj);
436-
}
430+
trailer.setItem(COSName.ID, idObj);
437431
}
438432
return true;
439433
}

0 commit comments

Comments
 (0)