Skip to content

fix: prevent PDF generation crash on non-latin-1 characters in AI output#114

Merged
advaitpatel merged 1 commit into
mainfrom
fixing-pdf-report-generation
Jun 24, 2026
Merged

fix: prevent PDF generation crash on non-latin-1 characters in AI output#114
advaitpatel merged 1 commit into
mainfrom
fixing-pdf-report-generation

Conversation

@advaitpatel

Copy link
Copy Markdown
Collaborator

PDF report generation crashes with FPDFUnicodeEncodingException when AI providers return text containing Unicode characters outside the latin-1 range — most commonly em-dashes (—) in CVE titles, but also en-dashes, smart quotes, and ellipses.

fpdf2's built-in helvetica font only supports latin-1 encoding. AI-generated text
(vulnerabilities, remediation steps, security risks, exposed credentials) is passed
directly to multi_cell without sanitization, causing the entire PDF generation step
to fail and produce an empty file.

Reproduced consistently when scanning images with CVE titles containing em-dashes,
for example:
Character "—" at index 41 in text is outside the range of characters supported
by the font used: "helvetica". Please consider using a Unicode font.

PDF report generation crashes with `FPDFUnicodeEncodingException` when AI providers
return text containing Unicode characters outside the latin-1 range — most commonly
em-dashes (—) in CVE titles, but also en-dashes, smart quotes, and ellipses.
@advaitpatel advaitpatel merged commit e7c499a into main Jun 24, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant