From d65626dcf0b5cb009929d9654c951aeb9e11b928 Mon Sep 17 00:00:00 2001 From: MyuTsu Date: Mon, 8 Sep 2025 17:05:13 +0200 Subject: [PATCH 1/5] fix(export): escape non-HTML tags --- inc/simplepdf.class.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/inc/simplepdf.class.php b/inc/simplepdf.class.php index 175f25d..bc624c8 100644 --- a/inc/simplepdf.class.php +++ b/inc/simplepdf.class.php @@ -346,6 +346,25 @@ public function displayText($name, $content = '', $minline = 3, $maxline = 100) $this->setColumnsSize(100); $text = $name . ' ' . $content; $content = Html::entity_decode_deep($text); + $allowed = [ + 'p','b','i','u','em','strong','br','span','div', + 'table','thead','tbody','tr','td','th', + 'ul','ol','li', + 'h1','h2','h3','h4','h5','h6', + 'a','pre','code','img', 'colgroup', 'col', + ]; + $content = preg_replace_callback( + '/<\/?([a-zA-Z0-9]+)(\s[^>]*)?>/', + function ($matches) use ($allowed) { + $tag = strtolower($matches[1]); + if (in_array($tag, $allowed)) { + return $matches[0]; // balise autorisée → on garde + } else { + return htmlspecialchars($matches[0], ENT_NOQUOTES, 'UTF-8'); // balise non autorisée → on escape + } + }, + $content + ); if (!preg_match("//", $content) && !preg_match('/

/', $content)) { $content = nl2br($content); } From 766c71fd466ec22a538ec49aa5511593eab61170 Mon Sep 17 00:00:00 2001 From: MyuTsu Date: Mon, 8 Sep 2025 17:18:00 +0200 Subject: [PATCH 2/5] CHANGELOG.md --- CHANGELOG.md | 1 + inc/simplepdf.class.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d31ee31..93b45c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [UNRELEASE] - Fix missing images in exported Knowledge Base PDFs +- escape non-HTML tags in PDF output ## [4.0.1] - 2025-03-10 diff --git a/inc/simplepdf.class.php b/inc/simplepdf.class.php index bc624c8..d9b33f1 100644 --- a/inc/simplepdf.class.php +++ b/inc/simplepdf.class.php @@ -358,12 +358,12 @@ public function displayText($name, $content = '', $minline = 3, $maxline = 100) function ($matches) use ($allowed) { $tag = strtolower($matches[1]); if (in_array($tag, $allowed)) { - return $matches[0]; // balise autorisée → on garde + return $matches[0]; } else { - return htmlspecialchars($matches[0], ENT_NOQUOTES, 'UTF-8'); // balise non autorisée → on escape + return htmlspecialchars($matches[0], ENT_NOQUOTES, 'UTF-8'); } }, - $content + $content, ); if (!preg_match("//", $content) && !preg_match('/

/', $content)) { $content = nl2br($content); From 096d2fd6b246f034a09ce4aa75c392d222f54540 Mon Sep 17 00:00:00 2001 From: MyuTsu Date: Tue, 9 Sep 2025 08:58:32 +0200 Subject: [PATCH 3/5] fix lint --- inc/appliance.class.php | 2 +- inc/cartridge.class.php | 2 +- inc/cartridgeitem.class.php | 2 +- inc/change.class.php | 2 +- inc/change_item.class.php | 2 +- inc/change_problem.class.php | 2 +- inc/change_ticket.class.php | 2 +- inc/changetask.class.php | 2 +- inc/changevalidation.class.php | 2 +- inc/common.class.php | 2 +- inc/commonitilcost.class.php | 2 +- inc/computer.class.php | 2 +- inc/computer_item.class.php | 2 +- inc/computer_softwarelicense.class.php | 2 +- inc/computer_softwareversion.class.php | 2 +- inc/computerantivirus.class.php | 2 +- inc/computervirtualmachine.class.php | 2 +- inc/consumableitem.class.php | 2 +- inc/contract.class.php | 2 +- inc/contract_item.class.php | 2 +- inc/document.class.php | 2 +- inc/domain_item.class.php | 2 +- inc/group.class.php | 2 +- inc/group_user.class.php | 2 +- inc/infocom.class.php | 2 +- inc/item_device.class.php | 2 +- inc/item_disk.class.php | 2 +- inc/item_knowbaseitem.class.php | 2 +- inc/item_operatingsystem.class.php | 2 +- inc/item_problem.class.php | 2 +- inc/item_softwarelicense.class.php | 2 +- inc/item_softwareversion.class.php | 2 +- inc/item_ticket.class.php | 2 +- inc/itilfollowup.class.php | 2 +- inc/itilsolution.class.php | 2 +- inc/knowbaseitem.class.php | 2 +- inc/link.class.php | 2 +- inc/log.class.php | 2 +- inc/monitor.class.php | 2 +- inc/networkequipment.class.php | 2 +- inc/networkport.class.php | 2 +- inc/peripheral.class.php | 2 +- inc/phone.class.php | 2 +- inc/printer.class.php | 2 +- inc/problem.class.php | 2 +- inc/problem_ticket.class.php | 2 +- inc/problemtask.class.php | 2 +- inc/reservation.class.php | 2 +- inc/software.class.php | 2 +- inc/softwarelicense.class.php | 2 +- inc/softwareversion.class.php | 2 +- inc/ticket.class.php | 2 +- inc/ticket_contract.class.php | 2 +- inc/ticketsatisfaction.class.php | 2 +- inc/tickettask.class.php | 2 +- inc/ticketvalidation.class.php | 2 +- inc/user.class.php | 2 +- 57 files changed, 57 insertions(+), 57 deletions(-) diff --git a/inc/appliance.class.php b/inc/appliance.class.php index ce0e287..cf23ca8 100644 --- a/inc/appliance.class.php +++ b/inc/appliance.class.php @@ -37,7 +37,7 @@ class PluginPdfAppliance extends PluginPdfCommon /** * @param $obj (defult NULL) **/ - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Appliance()); } diff --git a/inc/cartridge.class.php b/inc/cartridge.class.php index 467e541..266368d 100644 --- a/inc/cartridge.class.php +++ b/inc/cartridge.class.php @@ -37,7 +37,7 @@ class PluginPdfCartridge extends PluginPdfCommon /** * @param $obj (defult NULL) **/ - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Cartridge()); } diff --git a/inc/cartridgeitem.class.php b/inc/cartridgeitem.class.php index af2a596..17a9644 100644 --- a/inc/cartridgeitem.class.php +++ b/inc/cartridgeitem.class.php @@ -34,7 +34,7 @@ class PluginPdfCartridgeItem extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new CartridgeItem()); } diff --git a/inc/change.class.php b/inc/change.class.php index d8405c6..2d6a8a3 100644 --- a/inc/change.class.php +++ b/inc/change.class.php @@ -34,7 +34,7 @@ class PluginPdfChange extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Change()); } diff --git a/inc/change_item.class.php b/inc/change_item.class.php index befcdd5..daebdde 100644 --- a/inc/change_item.class.php +++ b/inc/change_item.class.php @@ -34,7 +34,7 @@ class PluginPdfChange_Item extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Change_Item()); } diff --git a/inc/change_problem.class.php b/inc/change_problem.class.php index cb7c03f..5bb0d1a 100644 --- a/inc/change_problem.class.php +++ b/inc/change_problem.class.php @@ -34,7 +34,7 @@ class PluginPdfChange_Problem extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Change_Problem()); } diff --git a/inc/change_ticket.class.php b/inc/change_ticket.class.php index 2a1ba78..bdf9537 100644 --- a/inc/change_ticket.class.php +++ b/inc/change_ticket.class.php @@ -34,7 +34,7 @@ class PluginPdfChange_Ticket extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Change_Ticket()); } diff --git a/inc/changetask.class.php b/inc/changetask.class.php index 0527618..a54058c 100644 --- a/inc/changetask.class.php +++ b/inc/changetask.class.php @@ -34,7 +34,7 @@ class PluginPdfChangeTask extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new ChangeTask()); } diff --git a/inc/changevalidation.class.php b/inc/changevalidation.class.php index 4fa840e..bc8d797 100644 --- a/inc/changevalidation.class.php +++ b/inc/changevalidation.class.php @@ -34,7 +34,7 @@ class PluginPdfChangeValidation extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new ChangeValidation()); } diff --git a/inc/common.class.php b/inc/common.class.php index a0d2981..7d6a289 100644 --- a/inc/common.class.php +++ b/inc/common.class.php @@ -40,7 +40,7 @@ abstract class PluginPdfCommon extends CommonGLPI /** * Constructor, should intialize $this->obj property **/ - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { if ($obj) { $this->obj = $obj; diff --git a/inc/commonitilcost.class.php b/inc/commonitilcost.class.php index e59eb40..2d01a00 100644 --- a/inc/commonitilcost.class.php +++ b/inc/commonitilcost.class.php @@ -34,7 +34,7 @@ class PluginPdfCommonItilCost extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new TicketCost()); } diff --git a/inc/computer.class.php b/inc/computer.class.php index 0020194..b88b448 100644 --- a/inc/computer.class.php +++ b/inc/computer.class.php @@ -34,7 +34,7 @@ class PluginPdfComputer extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Computer()); } diff --git a/inc/computer_item.class.php b/inc/computer_item.class.php index a57f48a..d1b4d14 100644 --- a/inc/computer_item.class.php +++ b/inc/computer_item.class.php @@ -34,7 +34,7 @@ class PluginPdfComputer_Item extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Computer_Item()); } diff --git a/inc/computer_softwarelicense.class.php b/inc/computer_softwarelicense.class.php index 60fc5e2..b401c57 100644 --- a/inc/computer_softwarelicense.class.php +++ b/inc/computer_softwarelicense.class.php @@ -34,7 +34,7 @@ class PluginPdfComputer_SoftwareLicense extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Item_SoftwareLicense()); } diff --git a/inc/computer_softwareversion.class.php b/inc/computer_softwareversion.class.php index c0b1bdd..23935d7 100644 --- a/inc/computer_softwareversion.class.php +++ b/inc/computer_softwareversion.class.php @@ -34,7 +34,7 @@ class PluginPdfComputer_SoftwareVersion extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Item_SoftwareVersion()); } diff --git a/inc/computerantivirus.class.php b/inc/computerantivirus.class.php index bcda467..d1f6e13 100644 --- a/inc/computerantivirus.class.php +++ b/inc/computerantivirus.class.php @@ -34,7 +34,7 @@ class PluginPdfComputerAntivirus extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new ComputerAntivirus()); } diff --git a/inc/computervirtualmachine.class.php b/inc/computervirtualmachine.class.php index dba0fe0..ab9afb8 100644 --- a/inc/computervirtualmachine.class.php +++ b/inc/computervirtualmachine.class.php @@ -34,7 +34,7 @@ class PluginPdfComputerVirtualMachine extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new ComputerVirtualMachine()); } diff --git a/inc/consumableitem.class.php b/inc/consumableitem.class.php index 58a5b3a..74df805 100644 --- a/inc/consumableitem.class.php +++ b/inc/consumableitem.class.php @@ -34,7 +34,7 @@ class PluginPdfConsumableItem extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new CartridgeItem()); } diff --git a/inc/contract.class.php b/inc/contract.class.php index 40c66ef..3461060 100644 --- a/inc/contract.class.php +++ b/inc/contract.class.php @@ -34,7 +34,7 @@ class PluginPdfContract extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Contract()); } diff --git a/inc/contract_item.class.php b/inc/contract_item.class.php index 2d13e88..daa8366 100644 --- a/inc/contract_item.class.php +++ b/inc/contract_item.class.php @@ -34,7 +34,7 @@ class PluginPdfContract_Item extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Contract_Item()); } diff --git a/inc/document.class.php b/inc/document.class.php index d736544..1b45280 100644 --- a/inc/document.class.php +++ b/inc/document.class.php @@ -34,7 +34,7 @@ class PluginPdfDocument extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Document()); } diff --git a/inc/domain_item.class.php b/inc/domain_item.class.php index 95f899f..4cfd664 100644 --- a/inc/domain_item.class.php +++ b/inc/domain_item.class.php @@ -34,7 +34,7 @@ class PluginPdfDomain_Item extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Domain_Item()); } diff --git a/inc/group.class.php b/inc/group.class.php index 5bf83a2..cd824bc 100644 --- a/inc/group.class.php +++ b/inc/group.class.php @@ -34,7 +34,7 @@ class PluginPdfGroup extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Group()); } diff --git a/inc/group_user.class.php b/inc/group_user.class.php index d33a59e..730e0a8 100644 --- a/inc/group_user.class.php +++ b/inc/group_user.class.php @@ -34,7 +34,7 @@ class PluginPdfGroup_User extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Group_User()); } diff --git a/inc/infocom.class.php b/inc/infocom.class.php index 0be5606..c618694 100644 --- a/inc/infocom.class.php +++ b/inc/infocom.class.php @@ -34,7 +34,7 @@ class PluginPdfInfocom extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Infocom()); } diff --git a/inc/item_device.class.php b/inc/item_device.class.php index 0ab2568..64d7af8 100644 --- a/inc/item_device.class.php +++ b/inc/item_device.class.php @@ -34,7 +34,7 @@ class PluginPdfItem_Device extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Item_Devices()); } diff --git a/inc/item_disk.class.php b/inc/item_disk.class.php index 2f34df7..f4befda 100644 --- a/inc/item_disk.class.php +++ b/inc/item_disk.class.php @@ -34,7 +34,7 @@ class PluginPdfItem_Disk extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Item_Disk()); } diff --git a/inc/item_knowbaseitem.class.php b/inc/item_knowbaseitem.class.php index ea94432..6bb6768 100644 --- a/inc/item_knowbaseitem.class.php +++ b/inc/item_knowbaseitem.class.php @@ -34,7 +34,7 @@ class PluginPdfItem_Knowbaseitem extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Item_Disk()); } diff --git a/inc/item_operatingsystem.class.php b/inc/item_operatingsystem.class.php index 6d94a51..f1c055f 100644 --- a/inc/item_operatingsystem.class.php +++ b/inc/item_operatingsystem.class.php @@ -34,7 +34,7 @@ class PluginPdfItem_OperatingSystem extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Item_OperatingSystem()); } diff --git a/inc/item_problem.class.php b/inc/item_problem.class.php index be76ac4..9cae4e1 100644 --- a/inc/item_problem.class.php +++ b/inc/item_problem.class.php @@ -34,7 +34,7 @@ class PluginPdfItem_Problem extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Item_Problem()); } diff --git a/inc/item_softwarelicense.class.php b/inc/item_softwarelicense.class.php index 25f4fce..b543e87 100644 --- a/inc/item_softwarelicense.class.php +++ b/inc/item_softwarelicense.class.php @@ -34,7 +34,7 @@ class PluginPdfItem_SoftwareLicense extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Item_SoftwareLicense()); } diff --git a/inc/item_softwareversion.class.php b/inc/item_softwareversion.class.php index 5ea5197..c21f93a 100644 --- a/inc/item_softwareversion.class.php +++ b/inc/item_softwareversion.class.php @@ -34,7 +34,7 @@ class PluginPdfItem_SoftwareVersion extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Item_SoftwareVersion()); } diff --git a/inc/item_ticket.class.php b/inc/item_ticket.class.php index f259b3b..039d7c0 100644 --- a/inc/item_ticket.class.php +++ b/inc/item_ticket.class.php @@ -34,7 +34,7 @@ class PluginPdfItem_Ticket extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Item_Ticket()); } diff --git a/inc/itilfollowup.class.php b/inc/itilfollowup.class.php index 4ce0ee3..8f5b08d 100644 --- a/inc/itilfollowup.class.php +++ b/inc/itilfollowup.class.php @@ -34,7 +34,7 @@ class PluginPdfItilFollowup extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new ITILFollowup()); } diff --git a/inc/itilsolution.class.php b/inc/itilsolution.class.php index 6d829c6..6a59bf7 100644 --- a/inc/itilsolution.class.php +++ b/inc/itilsolution.class.php @@ -34,7 +34,7 @@ class PluginPdfITILSolution extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new ITILSolution()); } diff --git a/inc/knowbaseitem.class.php b/inc/knowbaseitem.class.php index c3e01a7..b8b5787 100644 --- a/inc/knowbaseitem.class.php +++ b/inc/knowbaseitem.class.php @@ -34,7 +34,7 @@ class PluginPdfKnowbaseItem extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new KnowbaseItem()); } diff --git a/inc/link.class.php b/inc/link.class.php index 1956c35..e8794ef 100644 --- a/inc/link.class.php +++ b/inc/link.class.php @@ -34,7 +34,7 @@ class PluginPdfLink extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Link()); } diff --git a/inc/log.class.php b/inc/log.class.php index 38d7b7f..58f6924 100644 --- a/inc/log.class.php +++ b/inc/log.class.php @@ -34,7 +34,7 @@ class PluginPdfLog extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Log()); } diff --git a/inc/monitor.class.php b/inc/monitor.class.php index 68f75c8..bfff18e 100644 --- a/inc/monitor.class.php +++ b/inc/monitor.class.php @@ -34,7 +34,7 @@ class PluginPdfMonitor extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Monitor()); } diff --git a/inc/networkequipment.class.php b/inc/networkequipment.class.php index 8048631..161622c 100644 --- a/inc/networkequipment.class.php +++ b/inc/networkequipment.class.php @@ -34,7 +34,7 @@ class PluginPdfNetworkEquipment extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new NetworkEquipment()); } diff --git a/inc/networkport.class.php b/inc/networkport.class.php index d95825d..a5005ec 100644 --- a/inc/networkport.class.php +++ b/inc/networkport.class.php @@ -36,7 +36,7 @@ class PluginPdfNetworkPort extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new NetworkPort()); } diff --git a/inc/peripheral.class.php b/inc/peripheral.class.php index b8d5e6a..ed868cf 100644 --- a/inc/peripheral.class.php +++ b/inc/peripheral.class.php @@ -34,7 +34,7 @@ class PluginPdfPeripheral extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Peripheral()); } diff --git a/inc/phone.class.php b/inc/phone.class.php index e524e0d..b3a8840 100644 --- a/inc/phone.class.php +++ b/inc/phone.class.php @@ -34,7 +34,7 @@ class PluginPdfPhone extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Phone()); } diff --git a/inc/printer.class.php b/inc/printer.class.php index 7e52e1a..08272da 100644 --- a/inc/printer.class.php +++ b/inc/printer.class.php @@ -34,7 +34,7 @@ class PluginPdfPrinter extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Printer()); } diff --git a/inc/problem.class.php b/inc/problem.class.php index 0aa6b86..f2bf915 100644 --- a/inc/problem.class.php +++ b/inc/problem.class.php @@ -34,7 +34,7 @@ class PluginPdfProblem extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Problem()); } diff --git a/inc/problem_ticket.class.php b/inc/problem_ticket.class.php index 1ede75e..61a7ded 100644 --- a/inc/problem_ticket.class.php +++ b/inc/problem_ticket.class.php @@ -34,7 +34,7 @@ class PluginPdfProblem_Ticket extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Problem_Ticket()); } diff --git a/inc/problemtask.class.php b/inc/problemtask.class.php index 5628cf4..aa99ff4 100755 --- a/inc/problemtask.class.php +++ b/inc/problemtask.class.php @@ -34,7 +34,7 @@ class PluginPdfProblemTask extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new ProblemTask()); } diff --git a/inc/reservation.class.php b/inc/reservation.class.php index ddbbf7d..1dc77af 100644 --- a/inc/reservation.class.php +++ b/inc/reservation.class.php @@ -34,7 +34,7 @@ class PluginPdfReservation extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Reservation()); } diff --git a/inc/software.class.php b/inc/software.class.php index 0aed64e..652d4c7 100644 --- a/inc/software.class.php +++ b/inc/software.class.php @@ -34,7 +34,7 @@ class PluginPdfSoftware extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Software()); } diff --git a/inc/softwarelicense.class.php b/inc/softwarelicense.class.php index e1d5337..f8db310 100644 --- a/inc/softwarelicense.class.php +++ b/inc/softwarelicense.class.php @@ -34,7 +34,7 @@ class PluginPdfSoftwareLicense extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new SoftwareLicense()); } diff --git a/inc/softwareversion.class.php b/inc/softwareversion.class.php index 69cf2c0..a4dc3b3 100644 --- a/inc/softwareversion.class.php +++ b/inc/softwareversion.class.php @@ -34,7 +34,7 @@ class PluginPdfSoftwareVersion extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new SoftwareVersion()); } diff --git a/inc/ticket.class.php b/inc/ticket.class.php index ff97a91..b74611c 100644 --- a/inc/ticket.class.php +++ b/inc/ticket.class.php @@ -34,7 +34,7 @@ class PluginPdfTicket extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Ticket()); } diff --git a/inc/ticket_contract.class.php b/inc/ticket_contract.class.php index a3f21e2..1ee269c 100644 --- a/inc/ticket_contract.class.php +++ b/inc/ticket_contract.class.php @@ -34,7 +34,7 @@ class PluginPdfTicket_Contract extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new Ticket_Contract()); } diff --git a/inc/ticketsatisfaction.class.php b/inc/ticketsatisfaction.class.php index fba361e..6d4555a 100644 --- a/inc/ticketsatisfaction.class.php +++ b/inc/ticketsatisfaction.class.php @@ -34,7 +34,7 @@ class PluginPdfTicketSatisfaction extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new TicketSatisfaction()); } diff --git a/inc/tickettask.class.php b/inc/tickettask.class.php index 57ad8a4..ce14193 100644 --- a/inc/tickettask.class.php +++ b/inc/tickettask.class.php @@ -34,7 +34,7 @@ class PluginPdfTicketTask extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new TicketTask()); } diff --git a/inc/ticketvalidation.class.php b/inc/ticketvalidation.class.php index 97e2159..bf1d617 100644 --- a/inc/ticketvalidation.class.php +++ b/inc/ticketvalidation.class.php @@ -34,7 +34,7 @@ class PluginPdfTicketValidation extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new TicketValidation()); } diff --git a/inc/user.class.php b/inc/user.class.php index b8aa49e..98456cc 100644 --- a/inc/user.class.php +++ b/inc/user.class.php @@ -34,7 +34,7 @@ class PluginPdfUser extends PluginPdfCommon { public static $rightname = 'plugin_pdf'; - public function __construct(CommonGLPI $obj = null) + public function __construct(?CommonGLPI $obj = null) { $this->obj = ($obj ? $obj : new User()); } From e49b03bcdffd8d5450cc18e06ca20cd055685036 Mon Sep 17 00:00:00 2001 From: MyuTsu Date: Tue, 9 Sep 2025 11:10:03 +0200 Subject: [PATCH 4/5] review --- inc/simplepdf.class.php | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/inc/simplepdf.class.php b/inc/simplepdf.class.php index d9b33f1..5c06d71 100644 --- a/inc/simplepdf.class.php +++ b/inc/simplepdf.class.php @@ -345,26 +345,7 @@ public function displayText($name, $content = '', $minline = 3, $maxline = 100) $this->setColumnsSize(100); $text = $name . ' ' . $content; - $content = Html::entity_decode_deep($text); - $allowed = [ - 'p','b','i','u','em','strong','br','span','div', - 'table','thead','tbody','tr','td','th', - 'ul','ol','li', - 'h1','h2','h3','h4','h5','h6', - 'a','pre','code','img', 'colgroup', 'col', - ]; - $content = preg_replace_callback( - '/<\/?([a-zA-Z0-9]+)(\s[^>]*)?>/', - function ($matches) use ($allowed) { - $tag = strtolower($matches[1]); - if (in_array($tag, $allowed)) { - return $matches[0]; - } else { - return htmlspecialchars($matches[0], ENT_NOQUOTES, 'UTF-8'); - } - }, - $content, - ); + $content = Glpi\RichText\RichText::getEnhancedHtml($text); if (!preg_match("//", $content) && !preg_match('/

/', $content)) { $content = nl2br($content); } From 2e3841224c2c26df6ed117844efa98a269567164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Langlois=20Ga=C3=ABtan?= <64356364+MyvTsv@users.noreply.github.com> Date: Tue, 9 Sep 2025 11:14:03 +0200 Subject: [PATCH 5/5] Update CHANGELOG.md Co-authored-by: Stanislas --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93b45c8..e7eed6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [UNRELEASE] - Fix missing images in exported Knowledge Base PDFs -- escape non-HTML tags in PDF output +- Enhanced display of HTML content ## [4.0.1] - 2025-03-10