From 9db0dc78c7f8f69e6bf7082942c05250ec950b0b Mon Sep 17 00:00:00 2001 From: Jake Jackson Date: Wed, 17 Apr 2024 12:56:35 +1000 Subject: [PATCH] Replace character entities with characters when processing the `code` attribute in the `` tag Resolves #1761 --- CHANGELOG.md | 5 +++++ src/Tag/BarCode.php | 2 +- tests/Issues/Issue1760Test.php | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/Issues/Issue1760Test.php diff --git a/CHANGELOG.md b/CHANGELOG.md index fc37aae83..a05d65086 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ New features * PHP 8.3 support in mPDF 8.2.1 * Add support for `page-break-before: avoid;` and `page-break-after: avoid;` for tr elements inside tables +Bugfixes +-------- + +* Replace character entities with characters when processing the `code` attribute in the `` tag + mPDF 8.1.x =========================== diff --git a/src/Tag/BarCode.php b/src/Tag/BarCode.php index a1c38e34f..40bf5dc41 100644 --- a/src/Tag/BarCode.php +++ b/src/Tag/BarCode.php @@ -33,7 +33,7 @@ public function open($attr, &$ahtml, &$ihtml) $objattr['border_bottom']['w'] = 0; $objattr['border_left']['w'] = 0; $objattr['border_right']['w'] = 0; - $objattr['code'] = $attr['CODE']; + $objattr['code'] = htmlspecialchars_decode($attr['CODE']); if (isset($attr['TYPE'])) { $objattr['btype'] = strtoupper(trim($attr['TYPE'])); diff --git a/tests/Issues/Issue1760Test.php b/tests/Issues/Issue1760Test.php new file mode 100644 index 000000000..b2410a556 --- /dev/null +++ b/tests/Issues/Issue1760Test.php @@ -0,0 +1,20 @@ +mpdf->WriteHTML('', HTMLParserMode::DEFAULT_MODE, true, false); + + $barcodeObj = $this->mpdf->_getObjAttr($this->mpdf->textbuffer[0][0]); + + $this->assertSame($originalCode, $barcodeObj['code']); + } +}