Skip to content

Commit

Permalink
fix: [eventreport:extractEntities] Enforced minimum amount of char fo…
Browse files Browse the repository at this point in the history
…r valid replacement
  • Loading branch information
mokaddem committed Oct 6, 2023
1 parent f8ed3a8 commit d72fbb7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/Model/EventReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,9 @@ public function transformFreeTextIntoReplacement(array $user, array $report, arr
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']])) {
Expand Down Expand Up @@ -784,6 +787,9 @@ public function extractWithReplacements(array $user, array $report, array $optio
$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'];
Expand Down

0 comments on commit d72fbb7

Please sign in to comment.