Skip to content

Commit e4d1022

Browse files
authored
Fix ticket task picture visibility (#9)
* Fix ticket task picture visibility * Fix Lints
1 parent e85d2e7 commit e4d1022

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

inc/tickettask.class.php

+15-2
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,22 @@ public static function pdfForTicket(PluginPdfSimplePDF $pdf, Ticket $job, $priva
145145
Toolbox::stripTags($dbu->getUserName($data['users_id'])),
146146
$planification,
147147
);
148+
$content = Glpi\Toolbox\Sanitizer::unsanitize(Html::entity_decode_deep($data['content']));
149+
$content = preg_replace('#data:image/[^;]+;base64,#', '@', $content);
150+
151+
preg_match_all('/<img [^>]*src=[\'"]([^\'"]*docid=([0-9]*))[^>]*>/', $content, $res, PREG_SET_ORDER);
152+
153+
foreach ($res as $img) {
154+
$docimg = new Document();
155+
$docimg->getFromDB($img[2]);
156+
157+
$path = '<img src="file://' . GLPI_DOC_DIR . '/' . $docimg->fields['filepath'] . '"/>';
158+
$content = str_replace($img[0], $path, $content);
159+
}
160+
148161
$pdf->displayText(
149-
'<b><i>' . sprintf(__('%1$s: %2$s') . '</i></b>', __('Description'), ''),
150-
'<br />' . $data['content'],
162+
"<b><i>" . sprintf(__('%1$s: %2$s') . "</i></b>", __('Description'), ''),
163+
$content,
151164
1,
152165
);
153166
}

0 commit comments

Comments
 (0)