File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -780,11 +780,7 @@ class NameObject(str, PdfObject): # noqa: SLOT000
780
780
delimiter_pattern = re .compile (rb"\s+|[\(\)<>\[\]{}/%]" )
781
781
surfix = b"/"
782
782
renumber_table : ClassVar [Dict [str , bytes ]] = {
783
- "#" : b"#23" ,
784
- "(" : b"#28" ,
785
- ")" : b"#29" ,
786
- "/" : b"#2F" ,
787
- "%" : b"#25" ,
783
+ ** {chr (i ): f"#{ i :02X} " .encode () for i in b"#()<>[]{}/%" },
788
784
** {chr (i ): f"#{ i :02X} " .encode () for i in range (33 )},
789
785
}
790
786
Original file line number Diff line number Diff line change @@ -243,11 +243,18 @@ def test_name_object(caplog):
243
243
assert bytes (b .getbuffer ()) == b"/DIJMAC+Arial#20Black#231"
244
244
assert caplog .text == ""
245
245
246
+ caplog .clear ()
246
247
b = BytesIO ()
247
248
NameObject ("/你好世界 (%)" ).write_to_stream (b )
248
249
assert bytes (b .getbuffer ()) == b"/#E4#BD#A0#E5#A5#BD#E4#B8#96#E7#95#8C#20#28#25#29"
249
250
assert caplog .text == ""
250
251
252
+ caplog .clear ()
253
+ b = BytesIO ()
254
+ NameObject ("/{foo}<bar>(baz)[qux]#/%" ).write_to_stream (b )
255
+ assert bytes (b .getbuffer ()) == b"/#7Bfoo#7D#3Cbar#3E#28baz#29#5Bqux#5D#23#2F#25"
256
+ assert caplog .text == ""
257
+
251
258
252
259
def test_destination_fit_r ():
253
260
d = Destination (
You can’t perform that action at this time.
0 commit comments