mpdf / mpdf

PHP library generating PDF files from UTF-8 encoded HTML

Home Page:https://mpdf.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Attribute value truncated when containing double quote character and using single quote delimiter

jakejackson1 opened this issue · comments

Guidelines

Description of the bug

It isn't possible to use double quote characters in HTML tag attributes when using single quotes as the delimiter e.g. <barcode code='{"t":1,"d":5}' type="qr"/>. mPDF will interpret this HTML as <barcode code="{"t":1,"d":5}" type="qr"/> and truncate code to {.

This bug stems from this area of code https://github.com/mpdf/mpdf/blob/development/src/Mpdf.php#L13861-L13862, which blindly converts single quotes to double quotes.

mPDF version

development

PHP Version and environment (server type, cli provider etc., enclosing libraries and their respective versions)

any

Reproducible PHP+CSS+HTML snippet suffering by the error

$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML('<barcode code=\'{"t":1,"d":5}\' type="qr"/>');
$mpdf->Output();