Skip to content

Commit

Permalink
Fix TypeError by Ignoring null characters in PSBaseParser (#768)
Browse files Browse the repository at this point in the history
* Ignore null characters in PSBaseParser

Beforehand, null characters were encoded as PSKeyword tokens. This caused
issue #617, as pdfdevice.py would attempt to decode the null character
PSKeyword, when it expects a byte string, as opposed to a PSKeyword, causing
pdfminer.six to crash.

As null characters are superfluous within PSBaseParser, ignore them.

* Update CHANGELOG.md

Co-authored-by: Pieter Marsman <[email protected]>
  • Loading branch information
cchristiansen and pietermarsman authored Jun 26, 2022
1 parent f63e9fb commit ebf92ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- `ValueError` when trying to decrypt empty metadata values ([#766](https://github.com/pdfminer/pdfminer.six/issues/766))
- Sphinx errors during building of documentation ([#760](https://github.com/pdfminer/pdfminer.six/pull/760))
- `TypeError` when getting default width of font ([#720](https://github.com/pdfminer/pdfminer.six/issues/720))
- `TypeError` in cmapdb.py when parsing null characters ([#768](https://github.com/pdfminer/pdfminer.six/pull/768))

### Deprecated

Expand Down
2 changes: 2 additions & 0 deletions pdfminer/psparser.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ def _parse_main(self, s: bytes, i: int) -> int:
self._curtoken = b""
self._parse1 = self._parse_wclose
return j + 1
elif c == b"\x00":
return j + 1
else:
self._add_token(KWD(c))
return j + 1
Expand Down

0 comments on commit ebf92ac

Please sign in to comment.