Skip to content

Commit

Permalink
BUG: Decode #23 in NameObject (#1342)
Browse files Browse the repository at this point in the history
Fixes #1340
  • Loading branch information
pubpub-zz authored Sep 10, 2022
1 parent 2bbccf7 commit d3a4a99
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions PyPDF2/generic/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,10 @@ def writeToStream(

@staticmethod
def unnumber(sin: str) -> str:
i = sin.find("#")
i = sin.find("#", 0)
while i >= 0:
sin = sin[:i] + chr(int(sin[i + 1 : i + 3], 16)) + sin[i + 3 :]
i = sin.find("#")
i = sin.find("#", i + 1)
return sin

@staticmethod
Expand Down
6 changes: 6 additions & 0 deletions tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ def test_NameObject():
== "/paired()parentheses"
)
assert NameObject.read_from_stream(BytesIO(b"/A#42"), None) == "/AB"
assert (
NameObject.read_from_stream(
BytesIO(b"/#f1j#d4#aa#0c#ce#87#b4#b3#b0#23J#86#fe#2a#b2jYJ#94"), None
)
== "/ñjÔª\x0cÎ\x87´³°#J\x86þ*²jYJ\x94"
)


def test_destination_fit_r():
Expand Down

0 comments on commit d3a4a99

Please sign in to comment.