From 4304fbaed5f501aed272f77569888232d41dd555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Cailly?= Date: Tue, 17 Sep 2024 16:32:32 +0200 Subject: [PATCH] fix: Fixed possible encodings issues --- src/Appliance.php | 2 +- src/Appliance_Item.php | 6 +++--- src/Appliance_Item_Relation.php | 12 ++++++------ src/Entity.php | 4 ++-- src/Html.php | 20 ++++++++++---------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Appliance.php b/src/Appliance.php index 2e3db8a959f2..86ffef5c5f59 100644 --- a/src/Appliance.php +++ b/src/Appliance.php @@ -518,7 +518,7 @@ public static function showMassiveActionsSubForm(MassiveAction $ma) switch ($ma->getAction()) { case 'add_item': Appliance::dropdown(); - echo Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']); + echo Html::submit(_sx('button', 'Post'), ['name' => 'massiveaction']); return true; } return parent::showMassiveActionsSubForm($ma); diff --git a/src/Appliance_Item.php b/src/Appliance_Item.php index a2aa0dc4da61..2e5c8cbb4ccd 100644 --- a/src/Appliance_Item.php +++ b/src/Appliance_Item.php @@ -150,7 +150,7 @@ public static function showItems(Appliance $appliance) echo ""; echo ""; echo ""; + __s('Add an item') . ""; echo ""; echo "
" . - __('Add an item') . "
"; Dropdown::showSelectItemFromItemtypes( @@ -167,7 +167,7 @@ public static function showItems(Appliance $appliance) ); echo ""; echo Html::hidden('appliances_id', ['value' => $ID]); - echo Html::submit(_x('button', 'Add'), ['name' => 'add']); + echo Html::submit(_sx('button', 'Add'), ['name' => 'add']); echo "
"; Html::closeForm(); @@ -257,7 +257,7 @@ public static function showForItem(CommonDBTM $item, $withtemplate = 0) echo ""; echo ""; - echo ""; + echo ""; echo ""; } @@ -264,7 +264,7 @@ public static function getListJSForApplianceItem( ]) . "

- " . Html::submit(_x('button', "Add"), ['name' => 'add']) . " + " . Html::submit(_sx('button', "Add"), ['name' => 'add']) . " " . Html::closeForm(false)); $crsf_token = Session::getNewCSRFToken(); @@ -275,7 +275,7 @@ public static function getListJSForApplianceItem( var appliances_items_id = $(this).data('appliances-items-id'); glpi_html_dialog({ - title: _x('button', "Add an item"), + title: _sx('button', "Add an item"), body: {$modal_html}, id: 'add_relation_dialog', show: function() { diff --git a/src/Entity.php b/src/Entity.php index ff29d07337a7..a2b7b58fbc45 100644 --- a/src/Entity.php +++ b/src/Entity.php @@ -3081,7 +3081,7 @@ public static function getEntitySelectorTree(): array foreach ($entities as $entities_id => &$entity) { $entity['key'] = $entities_id; - $title = "{$entity['name']}"; + $title = "" . htmlspecialchars($entities['name']) . ""; $entity['title'] = $title; unset($entity['name']); @@ -3089,7 +3089,7 @@ public static function getEntitySelectorTree(): array $entity['folder'] = true; $entity['title'] .= " - + "; $children = $adapt_tree($entity['tree']); diff --git a/src/Html.php b/src/Html.php index 468abf574684..fc40e8cb7281 100644 --- a/src/Html.php +++ b/src/Html.php @@ -2588,7 +2588,7 @@ public static function showMassiveActions($options = []) ] ); } - $out .= "'; + $text = __s('Available variables') . ' '; echo Html::link($text, $link, $params); } @@ -3967,7 +3967,7 @@ public static function printAjaxPager($title, $start, $numrows, $additional_info // Print the "where am I?" $out .= "\n"; // Forward and fast forward button @@ -4050,7 +4050,7 @@ public static function printCleanArray($tab, $pad = 0, $jsexpand = false) } echo "
" . __('Add to an appliance') . "
" . __s('Add to an appliance') . "
"; Appliance::dropdown([ diff --git a/src/Appliance_Item_Relation.php b/src/Appliance_Item_Relation.php index 40a1f4f45de3..5a6f406dd096 100644 --- a/src/Appliance_Item_Relation.php +++ b/src/Appliance_Item_Relation.php @@ -194,8 +194,8 @@ public static function getForApplianceItem(int $appliances_items_id = 0) $itemtype = $row['itemtype']; $item = new $itemtype(); $item->getFromDB($row['items_id']); - $relations[$row['id']] = "" . - " " . $item::getTypeName(1) . + $relations[$row['id']] = "" . + " " . htmlspecialchars($item::getTypeName(1)) . " - " . $item->getLink(); } @@ -227,8 +227,8 @@ public static function showListForApplianceItem(int $appliances_items_id = 0, bo return "
    $relations_str
- - " . __('New relation') . " + + " . __s('New relation') . "
"; //TRANS: %1$d, %2$d, %3$d are page numbers - $out .= sprintf(__('From %1$d to %2$d of %3$d'), $current_start, $current_end, $numrows); + $out .= sprintf(__s('From %1$d to %2$d of %3$d'), $current_start, $current_end, $numrows); $out .= "
"; } else { - echo __('Empty array'); + echo __s('Empty array'); } } @@ -4182,7 +4182,7 @@ public static function printPager( echo ""; //TRANS: %1$d, %2$d, %3$d are page numbers - printf(__('From %1$d to %2$d of %3$d'), $current_start, $current_end, $numrows); + printf(__s('From %1$d to %2$d of %3$d'), $current_start, $current_end, $numrows); echo ""; // Forward and fast forward button @@ -4224,11 +4224,11 @@ public static function printPagerForm($action = "", $display = true, $additional $out = ''; if ($action) { $out .= "
"; - $out .= "" . __('Display (number of items)') . " "; + $out .= "" . __s('Display (number of items)') . " "; $out .= Dropdown::showListLimit("submit()", false); } else { $out .= "\n"; - $out .= "" . __('Display (number of items)') . " "; + $out .= "" . __s('Display (number of items)') . " "; $out .= Dropdown::showListLimit("reloadTab(\"glpilist_limit=\"+this.value+\"$additional_params\")", false); } $out .= Html::closeForm(false); @@ -5224,7 +5224,7 @@ public static function file($options = []) if ($p['showtitle']) { $display .= ""; - $display .= sprintf(__('%1$s (%2$s)'), __('File(s)'), Document::getMaxUploadSize()); + $display .= sprintf(__s('%1$s (%2$s)'), __s('File(s)'), Document::getMaxUploadSize()); $display .= DocumentType::showAvailableTypesLink([ 'display' => false, 'rand' => $p['rand'] @@ -5343,8 +5343,8 @@ function(index, file) { ); }, messages: { - acceptFileTypes: __('Filetype not allowed'), - maxFileSize: __('File is too big'), + acceptFileTypes: __s('Filetype not allowed'), + maxFileSize: __s('File is too big'), }, $progressall_js });