Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fixed PHP warnings flood when exporting Changes with linked items lacking serial/inventory fields
- Fixed Change and Problem description exported as a single unstructured text block
- Fixed Change analysis and plan fields rendering as raw HTML in PDF
- Fixed rich text content rendered as visible HTML tags and unformatted text in PDF exports

## [4.0.2] - 2025-09-30

Expand Down
7 changes: 4 additions & 3 deletions inc/simplepdf.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,12 @@ public function displayText($name, $content = '', $minline = 3, $maxline = 100)
$save = [$this->cols, $this->colsx, $this->colsw, $this->align];

$this->setColumnsSize(100);
$text = $name . ' ' . $content;
$content = Glpi\RichText\RichText::getEnhancedHtml($text, ['text_maxsize' => 0]);
// Decode $content alone: mixing literal HTML from $name breaks isHtmlEncoded(), leaving GLPI entities (<) un-decoded and visible as text in TCPDF.
$decoded = Glpi\RichText\RichText::getEnhancedHtml($content ?? '', ['text_maxsize' => 0]);
$text = preg_replace('/<script\b[^>]*>.*?<\/script>/is', '', $name . ' ' . $decoded);

// Split content by tables, keeping tables in the result
$segments = preg_split('/(<table\b[^>]*>.*?<\/table>)/is', $content, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
$segments = preg_split('/(<table\b[^>]*>.*?<\/table>)/is', $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);

// Process segments and rebuild content
$formatted_content = '';
Expand Down