Skip to content

Commit

Permalink
FIX : cope with cmap from #1322 (#1372)
Browse files Browse the repository at this point in the history
Cope with cmap where the range contains first and last code are on variable length.

Also fixes cases where the code is on 3 characters only (not standard).
No test data is available.

Fixes #1322
  • Loading branch information
pubpub-zz authored Sep 28, 2022
1 parent d9aa64c commit f3b6d0e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions PyPDF2/_cmap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import warnings
from binascii import unhexlify
from math import ceil
from typing import Any, Dict, List, Tuple, Union, cast

from ._codecs import adobe_glyphs, charset_encoding
Expand Down Expand Up @@ -267,9 +268,9 @@ def parse_bfrange(
) -> Union[None, Tuple[int, int]]:
lst = [x for x in l.split(b" ") if x]
closure_found = False
nbi = len(lst[0])
map_dict[-1] = nbi // 2
fmt = b"%%0%dX" % nbi
nbi = max(len(lst[0]), len(lst[1]))
map_dict[-1] = ceil(nbi / 2)
fmt = b"%%0%dX" % (map_dict[-1] * 2)
if multiline_rg is not None:
a = multiline_rg[0] # a, b not in the current line
b = multiline_rg[1]
Expand Down

0 comments on commit f3b6d0e

Please sign in to comment.