[Bug]: pdf.js doesn't lex `5f` properly
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 53.9k
- Forks
- 10.7k
- Avg merge
- 18h 38m
- Merged PRs (30d)
- 130
Description
Attach (recommended) or Link to PDF file
Web browser and its version
Firefox Nightly
Operating system and its version
macOS
PDF.js version
recent
Is the bug present in the latest PDF.js version?
Yes
Is a browser extension
No
Steps to reproduce the problem
- Load lex-diff.pdf
- Observe a large red rectangle
What is the expected behavior?
The PDF should not have a red rectangle. Acrobat, Preview and PDFium do not have a red rectangle.
What went wrong?
In a PDF stream like:
q
1 0 0 rg
100 450 400 150 re
5f
Q
pdf.js will lex 5f as Number(5), Keyword(f).
From PDF spec 7.2.3:
"All characters except the white-space characters and delimiters are referred to as regular characters. These characters include bytes that are outside the ASCII character set. A sequence of consecutive regular characters comprises a single token."
Link to a viewer
No response
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by loading the attached lex-diff.pdf in Firefox Nightly and inspect PDF.js's lexer for how it handles the stream token 5f. Compare the result with Acrobat, Preview, and PDFium; done means 5f is treated as one token and the red rectangle no longer appears.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100