EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
Ref
Yuriif6d726f4613d
diff --git a/application/Espo/Tools/Pdf/Dompdf/HtmlComposer.php b/application/Espo/Tools/Pdf/Dompdf/HtmlComposer.phpindex f0786c8be8..1436874e57 100644--- a/application/Espo/Tools/Pdf/Dompdf/HtmlComposer.php+++ b/application/Espo/Tools/Pdf/Dompdf/HtmlComposer.php@@ -37,6 +37,7 @@ use Espo\Tools\Pdf\Data;use Espo\Tools\Pdf\Params;use Espo\Tools\Pdf\Template;+use Espo\Tools\Pdf\Util\RegExp;use Picqer\Barcode\BarcodeGeneratorSVG;use Picqer\Barcode\Exceptions\UnknownTypeException;@@ -185,40 +186,31 @@ class HtmlComposer{/** @noinspection HtmlUnknownAttribute */$html = str_replace('<br pagebreak="true">', '<div style="page-break-after: always;"></div>', $html);- $html = preg_replace('/src="@([A-Za-z0-9+\/]*={0,2})"/', 'src="data:image/jpeg;base64,$1"', $html);- $html = str_replace('?entryPoint=attachment&', '?entryPoint=attachment&', $html ?? '');+ $html = preg_replace('/src="@([A-Za-z0-9+\/]*={0,2})"/', 'src="data:image/jpeg;base64,$1"', $html) ?? '';- $html = preg_replace_callback(- '/<barcodeimage data="([^"]+)"\/>/',- function ($matches) {- $dataString = $matches[1];+ $html = preg_replace_callback(RegExp::BARCODE, function ($matches) {+ $dataString = $matches[1];- $data = json_decode(urldecode($dataString), true);+ $data = json_decode(urldecode($dataString), true);- return $this->composeBarcode($data);- },- $html- ) ?? '';+ return $this->composeBarcode($data);+ }, $html) ?? '';- return preg_replace_callback(- "/src=\"\?entryPoint=attachment&id=([A-Za-z0-9\-]*)\"/",- function ($matches) {- $id = $matches[1];+ return preg_replace_callback(RegExp::INLINE_ATTACHMENT, function ($matches) {+ $id = $matches[1];- if (!$id) {- return '';- }+ if (!$id) {+ return '';+ }- $src = $this->imageSourceProvider->get($id);+ $src = $this->imageSourceProvider->get($id);- if (!$src) {- return '';- }+ if (!$src) {+ return '';+ }- return "src=\"$src\"";- },- $html- ) ?? '';+ return "src=\"$src\"";+ }, $html) ?? '';}private function replaceHeadTags(string $html): stringdiff --git a/application/Espo/Tools/Pdf/Util/RegExp.php b/application/Espo/Tools/Pdf/Util/RegExp.phpnew file mode 100644index 0000000000..a33a8ea3ef--- /dev/null+++ b/application/Espo/Tools/Pdf/Util/RegExp.php@@ -0,0 +1,38 @@+<?php+/************************************************************************+ * This file is part of EspoCRM.+ *+ * EspoCRM – Open Source CRM application.+ * Copyright (C) 2014-2026 EspoCRM, Inc.+ * Website: https://www.espocrm.com+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as published by+ * the Free Software Foundation, either version 3 of the License, or+ * (at your option) any later version.+ *+ * This program is distributed in the hope that it will be useful,+ * but WITHOUT ANY WARRANTY; without even the implied warranty of+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ * GNU Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <https://www.gnu.org/licenses/>.+ *+ * The interactive user interfaces in modified source and object code versions+ * of this program must display Appropriate Legal Notices, as required under+ * Section 5 of the GNU Affero General Public License version 3.+ *+ * In accordance with Section 7(b) of the GNU Affero General Public License version 3,+ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.+ ************************************************************************/++namespace Espo\Tools\Pdf\Util;++class RegExp+{+ public const string INLINE_ATTACHMENT = "/src=\"\?entryPoint=attachment(?:&|&)id=([A-Za-z0-9\-]*)\"/";++ /** @noinspection SpellCheckingInspection */+ public const string BARCODE = '/<barcodeimage ' . 'data="([^"]+)"\/>/';+}