Skip to content

Commit

Permalink
readObjectHeader: Allow extra whitespace before "obj"
Browse files Browse the repository at this point in the history
The header being read has the format:

    <idnum> <generation> obj

where `<idnum>` and `<generation>` are integers.
Previously an arbitrary number of spaces was being allowed between `<idnum>` and `<generation>`, but not between `<generation>` and `obj`.
We now allow arbitrary spaces between `<generation>` and `obj`.
  • Loading branch information
malthejorgensen committed Apr 16, 2022
1 parent a5875c5 commit 0184fda
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions PyPDF2/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,19 @@
__maintainer__ = "Phaseit, Inc."
__maintainer_email = "[email protected]"

import codecs
import math
import struct
import sys
import uuid
import warnings
from sys import version_info

from . import utils
from .generic import *
from .utils import (ConvertFunctionsToVirtualList, b_, formatWarning, isString,
ord_, readNonWhitespace, readUntilWhitespace, str_, u_)

if version_info < ( 3, 0 ):
from cStringIO import StringIO
else:
Expand All @@ -54,12 +62,6 @@
else:
from io import BytesIO

from . import utils
import warnings
import codecs
from .generic import *
from .utils import readNonWhitespace, readUntilWhitespace, ConvertFunctionsToVirtualList
from .utils import isString, b_, u_, ord_, str_, formatWarning

if version_info < ( 2, 4 ):
from sets import ImmutableSet as frozenset
Expand Down Expand Up @@ -1734,6 +1736,7 @@ def readObjectHeader(self, stream):
idnum = readUntilWhitespace(stream)
extra |= utils.skipOverWhitespace(stream); stream.seek(-1, 1)
generation = readUntilWhitespace(stream)
extra |= utils.skipOverWhitespace(stream); stream.seek(-1, 1)

# although it's not used, it might still be necessary to read
_obj = stream.read(3) # noqa: F841
Expand Down

0 comments on commit 0184fda

Please sign in to comment.