From 0869265428372e9ea6383dee31f5747caf68c138 Mon Sep 17 00:00:00 2001 From: RomainLvr Date: Wed, 15 Jan 2025 10:38:54 +0100 Subject: [PATCH 1/2] Fix ticket task picture visibility --- inc/tickettask.class.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/inc/tickettask.class.php b/inc/tickettask.class.php index 30bea08..8202dfc 100644 --- a/inc/tickettask.class.php +++ b/inc/tickettask.class.php @@ -145,10 +145,23 @@ public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job, $priva Toolbox::stripTags($dbu->getUserName($data['users_id'])), $planification, ); + $content = Glpi\Toolbox\Sanitizer::unsanitize(Html::entity_decode_deep($data['content'])); + $content = preg_replace('#data:image/[^;]+;base64,#', '@', $content); + + preg_match_all('/]*src=[\'"]([^\'"]*docid=([0-9]*))[^>]*>/', $content, $res, PREG_SET_ORDER); + + foreach ($res as $img) { + $docimg = new Document(); + $docimg->getFromDB($img[2]); + + $path = ''; + $content = str_replace($img[0], $path, $content); + } + $pdf->displayText( - '' . sprintf(__('%1$s: %2$s') . '', __('Description'), ''), - '
' . $data['content'], - 1, + "" . sprintf(__('%1$s: %2$s') . "", __('Description'), ''), + $content, + 1 ); } } From 6927af4c5b8d5f349ce615a6da78c3f017af3775 Mon Sep 17 00:00:00 2001 From: RomainLvr Date: Wed, 15 Jan 2025 10:47:15 +0100 Subject: [PATCH 2/2] Fix Lints --- inc/tickettask.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/tickettask.class.php b/inc/tickettask.class.php index 8202dfc..82b4693 100644 --- a/inc/tickettask.class.php +++ b/inc/tickettask.class.php @@ -154,14 +154,14 @@ public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job, $priva $docimg = new Document(); $docimg->getFromDB($img[2]); - $path = ''; + $path = ''; $content = str_replace($img[0], $path, $content); } $pdf->displayText( "" . sprintf(__('%1$s: %2$s') . "", __('Description'), ''), $content, - 1 + 1, ); } }