Skip to content

Commit

Permalink
PluginOutput: Return correctly cut off output
Browse files Browse the repository at this point in the history
If the output contains a cut off HTML element, it merges the next list-item into the same tag, because the end tag is missing.
In this case, the output must cut off up to the last valid string(part).
  • Loading branch information
sukhwinder33445 committed Jun 17, 2024
1 parent 6029cc1 commit ebbf0af
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion library/Icingadb/Util/PluginOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,14 @@ public function render()
$output = $this->processHtml($output);
}

if ($this->characterLimit) {
if (strlen($output) > $this->characterLimit) {

Check failure on line 205 in library/Icingadb/Util/PluginOutput.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$string of function strlen expects string, string\|null given\.$# in path /home/runner/work/icingadb-web/icingadb-web/library/Icingadb/Util/PluginOutput.php is expected to occur 1 time, but occurred 2 times.

Check failure on line 205 in library/Icingadb/Util/PluginOutput.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$string of function strlen expects string, string\|null given\.$# in path /home/runner/work/icingadb-web/icingadb-web/library/Icingadb/Util/PluginOutput.php is expected to occur 1 time, but occurred 2 times.

Check failure on line 205 in library/Icingadb/Util/PluginOutput.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$string of function strlen expects string, string\|null given\.$# in path /home/runner/work/icingadb-web/icingadb-web/library/Icingadb/Util/PluginOutput.php is expected to occur 1 time, but occurred 2 times.

Check failure on line 205 in library/Icingadb/Util/PluginOutput.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$string of function strlen expects string, string\|null given\.$# in path /home/runner/work/icingadb-web/icingadb-web/library/Icingadb/Util/PluginOutput.php is expected to occur 1 time, but occurred 2 times.

Check failure on line 205 in library/Icingadb/Util/PluginOutput.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$string of function strlen expects string, string\|null given\.$# in path /home/runner/work/icingadb-web/icingadb-web/library/Icingadb/Util/PluginOutput.php is expected to occur 1 time, but occurred 2 times.

Check failure on line 205 in library/Icingadb/Util/PluginOutput.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$string of function strlen expects string, string\|null given\.$# in path /home/runner/work/icingadb-web/icingadb-web/library/Icingadb/Util/PluginOutput.php is expected to occur 1 time, but occurred 2 times.

Check failure on line 205 in library/Icingadb/Util/PluginOutput.php

View workflow job for this annotation

GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest

Ignored error pattern #^Parameter \#1 \$string of function strlen expects string, string\|null given\.$# in path /home/runner/work/icingadb-web/icingadb-web/library/Icingadb/Util/PluginOutput.php is expected to occur 1 time, but occurred 2 times.
$output = substr($output, 0, $this->characterLimit);

// Remove the last output/html element if it is cut off to display only valid content
$endAt = strrpos($output, '\\_');
if ($endAt !== false) {
$output = rtrim(substr($output, 0, $endAt));
}
}

$this->renderedOutput = $output;
Expand Down

0 comments on commit ebbf0af

Please sign in to comment.