Skip to content

EspoCRM – Open Source CRM Application

fix markdown backend

Yurii27b1ce882b74
diff --git a/application/Espo/Classes/TemplateHelpers/MarkdownText.php b/application/Espo/Classes/TemplateHelpers/MarkdownText.php
index 3443b6d307..5b777e3ba7 100644
--- a/application/Espo/Classes/TemplateHelpers/MarkdownText.php
+++ b/application/Espo/Classes/TemplateHelpers/MarkdownText.php
@@ -32,7 +32,7 @@ namespace Espo\Classes\TemplateHelpers;
use Espo\Core\Htmlizer\Helper;
use Espo\Core\Htmlizer\Helper\Data;
use Espo\Core\Htmlizer\Helper\Result;
-use Michelf\MarkdownExtra as MarkdownTransformer;
+use Espo\Core\Utils\Markdown\Markdown;
class MarkdownText implements Helper
{
@@ -44,7 +44,7 @@ class MarkdownText implements Helper
return Result::createEmpty();
}
- $transformed = MarkdownTransformer::defaultTransform($value);
+ $transformed = Markdown::transform($value);
return Result::createSafeString($transformed);
}
diff --git a/application/Espo/Core/Formula/Functions/ExtGroup/MarkdownGroup/TransformType.php b/application/Espo/Core/Formula/Functions/ExtGroup/MarkdownGroup/TransformType.php
index 3e64f32773..913876c9c5 100644
--- a/application/Espo/Core/Formula/Functions/ExtGroup/MarkdownGroup/TransformType.php
+++ b/application/Espo/Core/Formula/Functions/ExtGroup/MarkdownGroup/TransformType.php
@@ -33,7 +33,7 @@ use Espo\Core\Formula\EvaluatedArgumentList;
use Espo\Core\Formula\Exceptions\BadArgumentType;
use Espo\Core\Formula\Exceptions\TooFewArguments;
use Espo\Core\Formula\Func;
-use Michelf\Markdown;
+use Espo\Core\Utils\Markdown\Markdown;
/**
* @noinspection PhpUnused
@@ -52,6 +52,6 @@ class TransformType implements Func
throw BadArgumentType::create(1, 'string');
}
- return Markdown::defaultTransform($string);
+ return Markdown::transform($string);
}
}
diff --git a/application/Espo/Core/Utils/Markdown/Markdown.php b/application/Espo/Core/Utils/Markdown/Markdown.php
new file mode 100644
index 0000000000..71692ae24e
--- /dev/null
+++ b/application/Espo/Core/Utils/Markdown/Markdown.php
@@ -0,0 +1,50 @@
+<?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\Core\Utils\Markdown;
+
+use Michelf\Markdown as MarkdownParser;
+
+/**
+ * @internal
+ */
+class Markdown
+{
+ /**
+ * @internal
+ */
+ public static function transform(string $text): string
+ {
+ $parser = new MarkdownParser();
+ $parser->no_markup = true;
+ $parser->no_entities = true;
+
+ return $parser->transform($text);
+ }
+}
diff --git a/application/Espo/Tools/EmailNotification/Processor.php b/application/Espo/Tools/EmailNotification/Processor.php
index 966f3e62a8..35f7070931 100644
--- a/application/Espo/Tools/EmailNotification/Processor.php
+++ b/application/Espo/Tools/EmailNotification/Processor.php
@@ -36,6 +36,7 @@ use Espo\Core\Notification\EmailNotificationHandler;
use Espo\Core\Mail\SenderParams;
use Espo\Core\Utils\Config\ApplicationConfig;
use Espo\Core\Utils\DateTime as DateTimeUtil;
+use Espo\Core\Utils\Markdown\Markdown;
use Espo\Entities\Note;
use Espo\ORM\Collection;
use Espo\Repositories\Portal as PortalRepository;
@@ -58,8 +59,6 @@ use Espo\Core\Utils\TemplateFileManager;
use Espo\Core\Utils\Util;
use Espo\Tools\Stream\NoteAccessControl;
-use Michelf\Markdown;
-
use Exception;
use DateTime;
use Throwable;
@@ -325,11 +324,10 @@ class Processor
$data['userName'] = $note->get('createdByName');
- $post = Markdown::defaultTransform(
- $note->get('post') ?? ''
- );
+ $post = $note->getPost() ?? '';
- $data['post'] = $post;
+
+ $data['post'] = Markdown::transform($post);
$subjectTpl = $this->templateFileManager->getTemplate('mention', 'subject');
$bodyTpl = $this->templateFileManager->getTemplate('mention', 'body');
@@ -486,9 +484,7 @@ class Processor
$data['userName'] = $note->get('createdByName');
- $post = Markdown::defaultTransform($note->getPost() ?? '');
-
- $data['post'] = $post;
+ $data['post'] = Markdown::transform($note->getPost() ?? '');
$parent = null;