Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG : fix stream truncated prematurly #1223

Merged
merged 6 commits into from Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions PyPDF2/generic.py
Expand Up @@ -492,6 +492,7 @@ def read_string_from_stream(
if ntok.isdigit():
tok += ntok
else:
stream.seek(-1, 1) # ntok has to be analysed
break
tok = b_(chr(int(tok, base=8)))
elif tok in b"\n\r":
Expand Down
7 changes: 6 additions & 1 deletion tests/test_generic.py
Expand Up @@ -157,7 +157,12 @@ def test_readStringFromStream_multichar_eol2():

def test_readStringFromStream_excape_digit():
stream = BytesIO(b"x\\1a )")
assert read_string_from_stream(stream) == "\x01 "
assert read_string_from_stream(stream) == "\x01a "


def test_readStringFromStream_excape_digit2():
stream = BytesIO(b"(hello \\1\\2\\3\\4)")
assert read_string_from_stream(stream) == "hello \x01\x02\x03\x04"


def test_NameObject():
Expand Down