ElementHexa "Invalid characters passed for attempted conversion, these have been ignored"
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.7k
- Forks
- 579
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
Came across a PDF making the ElementHexa decode() throw exceptions at
hexdec($hex_string = '00\n0') ..../pdfparser/src/Smalot/PdfParser/Element/ElementHexa.php:78
For some strange reason when decoding the parseHeaderElement the value passed has '\n' characters.
The solution I've applied is to add at line 73 of ElementHexa.php
$value = preg_replace('/\n/i', '', $value);
Hope this helps.
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 in pdfparser/src/Smalot/PdfParser/Element/ElementHexa.php around line 78, where hexdec() receives the value from parseHeaderElement. Reproduce the reported PDF case with a value containing a newline, then verify that ElementHexa::decode() completes without throwing and preserves the expected decoded result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100