fix: [eventreport:extractEntities] Enforced minimum amount of char for valid replacement

pull/9329/head
Sami Mokaddem 2023-10-06 15:40:24 +02:00
parent f8ed3a8d6d
commit d72fbb7c45
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 6 additions and 0 deletions

View File

@ -643,6 +643,9 @@ class EventReport extends AppModel
foreach ($proxyElements['attribute'] as $uuid => $attribute) {
$count = 0;
$textToInject = sprintf('@[attribute](%s)', $uuid);
if (strlen($attribute['value']) < 3) {
continue;
}
$content = str_replace($attribute['value'], $textToInject, $content, $count);
if ($count > 0 || strpos($originalContent, $attribute['value'])) { // Check if the value has been replaced by the first match
if (!isset($replacedValues[$attribute['value']])) {
@ -784,6 +787,9 @@ class EventReport extends AppModel
$tags = $this->Tag->fetchUsableTags($user);
foreach ($tags as $tag) {
$tagName = $tag['Tag']['name'];
if (strlen($tagName) < 3) {
continue;
}
$found = $this->isValidReplacementTag($content, $tagName);
if ($found) {
$replacedContext[$tagName][$tagName] = $tag['Tag'];