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

PI: Avoid string concatenation with large embedded base64-encoded images #1350

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions PyPDF2/generic/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def read_string_from_stream(
) -> Union["TextStringObject", "ByteStringObject"]:
tok = stream.read(1)
parens = 1
txt = b""
txt = []
while True:
tok = stream.read(1)
if not tok:
Expand Down Expand Up @@ -106,8 +106,8 @@ def read_string_from_stream(
else:
msg = rf"Unexpected escaped string: {tok.decode('utf8')}"
logger_warning(msg, __name__)
txt += tok
return create_string_object(txt, forced_encoding)
txt.append(tok)
return create_string_object(b''.join(txt), forced_encoding)


def create_string_object(
Expand Down