Skip to content

fix: prevent PDF export crash on tables with nested quotes in inline styles - #86

Open
Herafia wants to merge 5 commits into
mainfrom
fix/tcpdf-nested-quotes-crash
Open

fix: prevent PDF export crash on tables with nested quotes in inline styles#86
Herafia wants to merge 5 commits into
mainfrom
fix/tcpdf-nested-quotes-crash

Conversation

@Herafia

@Herafia Herafia commented Aug 25, 2026

Copy link
Copy Markdown

Checklist before requesting a review

Please delete options that are not relevant.

  • I have performed a self-review of my code.
  • I have added tests (when available) that prove my fix is effective or that my feature works.
  • I have updated the CHANGELOG with a short functional description of the fix or new feature.
  • This change requires a documentation update.

Description

  • It fixes !45825
  • The PDF export would crash on tickets whose descriptions contained an html table with styles using url(‘...’) (nested quotes). The regular expressions in cleanTableHtml would break the html at these quotes, corrupting the table structure and causing tcpdf to lose track of the cells.

Fix: Replaced the regular expressions with DOMDocument/DOMXPath parsing in cleanTableHtml, which is robust against nested quotes.

@Herafia Herafia changed the title fix: prevent PDF export crash on tables with nested quotes in inline … fix: prevent PDF export crash on tables with nested quotes in inline styles Aug 25, 2026
@Herafia Herafia self-assigned this Aug 25, 2026
@Herafia
Herafia requested review from Rom1-B and stonebuzz August 25, 2026 12:17
Comment thread inc/simplepdf.class.php

// Remove table-layout:fixed style (prevents auto-sizing)
$html = preg_replace('/table-layout\s*:\s*fixed\s*;?/i', '', $html);
// Parse with DOMDocument rather than regexes: style/attribute values coming

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a unit test for cleanTableHtml() with a nested-quote url('...') style value (case from !45825)? Verified locally that the old regex code produced a <table> with duplicate border/style attributes on this input, the actual crash mechanism, and that the new code doesn't; a test would pin the regression.

@Herafia
Herafia requested a review from Rom1-B August 25, 2026 14:42
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.

2 participants