Skip to content

Commit

Permalink
fix: Fixed possible encodings issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ccailly committed Sep 17, 2024
1 parent b952a20 commit 98cce0a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/Appliance.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/Appliance_Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static function showItems(Appliance $appliance)
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'>";
echo "<th colspan='2'>" .
__('Add an item') . "</th></tr>";
__s('Add an item') . "</th></tr>";

echo "<tr class='tab_bg_1'><td class='center'>";
Dropdown::showSelectItemFromItemtypes(
Expand All @@ -167,7 +167,7 @@ public static function showItems(Appliance $appliance)
);
echo "</td><td class='center' class='tab_bg_1'>";
echo Html::hidden('appliances_id', ['value' => $ID]);
echo Html::submit(_x('button', 'Add'), ['name' => 'add']);
echo Html::submit(_sx('button', 'Add'), ['name' => 'add']);
echo "</td></tr>";
echo "</table>";
Html::closeForm();
Expand Down Expand Up @@ -257,7 +257,7 @@ public static function showForItem(CommonDBTM $item, $withtemplate = 0)
echo "<input type='hidden' name='itemtype' value='$itemtype'>";

echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add to an appliance') . "</th></tr>";
echo "<tr class='tab_bg_2'><th colspan='2'>" . __s('Add to an appliance') . "</th></tr>";

echo "<tr class='tab_bg_1'><td>";
Appliance::dropdown([
Expand Down
12 changes: 6 additions & 6 deletions src/Appliance_Item_Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']] = "<i class='" . $item->getIcon() . "' title='" . $item::getTypeName(1) . "'></i>" .
"&nbsp;" . $item::getTypeName(1) .
$relations[$row['id']] = "<i class='" . $item->getIcon() . "' title='" . htmlspecialchars($item::getTypeName(1)) . "'></i>" .
"&nbsp;" . htmlspecialchars($item::getTypeName(1)) .
"&nbsp;-&nbsp;" . $item->getLink();
}

Expand Down Expand Up @@ -227,8 +227,8 @@ public static function showListForApplianceItem(int $appliances_items_id = 0, bo

return "<ul>$relations_str</ul>
<span class='cursor-pointer add_relation' data-appliances-items-id='{$appliances_items_id}'>
<i class='ti ti-plus' title='" . __('New relation') . "'></i>
<span class='sr-only'>" . __('New relation') . "</span>
<i class='ti ti-plus' title='" . __s('New relation') . "'></i>
<span class='sr-only'>" . __s('New relation') . "</span>
</span>
</td>";
}
Expand Down Expand Up @@ -264,7 +264,7 @@ public static function getListJSForApplianceItem(
])
. "</p>
<input type='hidden' name='appliances_items_id'>
" . Html::submit(_x('button', "Add"), ['name' => 'add']) . "
" . Html::submit(_sx('button', "Add"), ['name' => 'add']) . "
" . Html::closeForm(false));

$crsf_token = Session::getNewCSRFToken();
Expand All @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions src/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -3081,15 +3081,15 @@ public static function getEntitySelectorTree(): array
foreach ($entities as $entities_id => &$entity) {
$entity['key'] = $entities_id;

$title = "<a href='$base_path?active_entity={$entities_id}'>{$entity['name']}</a>";
$title = "<a href='$base_path?active_entity={$entities_id}'>" . htmlspecialchars($entities['name']) . "</a>";
$entity['title'] = $title;
unset($entity['name']);

if (isset($entity['tree']) && count($entity['tree']) > 0) {
$entity['folder'] = true;

$entity['title'] .= "<a href='$base_path?active_entity={$entities_id}&is_recursive=1'>
<i class='fas fa-angle-double-down ms-1' data-bs-toggle='tooltip' data-bs-placement='right' title='" . __('+ sub-entities') . "'></i>
<i class='fas fa-angle-double-down ms-1' data-bs-toggle='tooltip' data-bs-placement='right' title='" . __s('+ sub-entities') . "'></i>
</a>";

$children = $adapt_tree($entity['tree']);
Expand Down
16 changes: 8 additions & 8 deletions src/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -2588,7 +2588,7 @@ public static function showMassiveActions($options = [])
]
);
}
$out .= "<a role=\"button\" title='" . __('Massive actions') . "'
$out .= "<a role=\"button\" title='" . __s('Massive actions') . "'
data-bs-toggle='tooltip' data-bs-placement='" . ($p['ontop'] ? "bottom" : "top") . "'
class='btn btn-sm btn-primary me-2' ";
if (is_array($p['confirm'] || strlen($p['confirm']))) {
Expand Down Expand Up @@ -3864,7 +3864,7 @@ public static function addTemplateDocumentationLink(
$params['id'] = $link_id;
}

$text = __('Available variables') . ' <i class="fas fa-question-circle"></i>';
$text = __s('Available variables') . ' <i class="fas fa-question-circle"></i>';

echo Html::link($text, $link, $params);
}
Expand Down Expand Up @@ -3967,7 +3967,7 @@ public static function printAjaxPager($title, $start, $numrows, $additional_info
// Print the "where am I?"
$out .= "<td width='50%' class='tab_bg_2 b'>";
//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 .= "</td>\n";

// Forward and fast forward button
Expand Down Expand Up @@ -4050,7 +4050,7 @@ public static function printCleanArray($tab, $pad = 0, $jsexpand = false)
}
echo "</table>";
} else {
echo __('Empty array');
echo __s('Empty array');
}
}

Expand Down Expand Up @@ -4182,7 +4182,7 @@ public static function printPager(

echo "<td width='20%' class='b'>";
//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 "</td>";

// Forward and fast forward button
Expand Down Expand Up @@ -4224,11 +4224,11 @@ public static function printPagerForm($action = "", $display = true, $additional
$out = '';
if ($action) {
$out .= "<form method='POST' action=\"$action\">";
$out .= "<span class='responsive_hidden'>" . __('Display (number of items)') . "</span>&nbsp;";
$out .= "<span class='responsive_hidden'>" . __s('Display (number of items)') . "</span>&nbsp;";
$out .= Dropdown::showListLimit("submit()", false);
} else {
$out .= "<form method='POST' action =''>\n";
$out .= "<span class='responsive_hidden'>" . __('Display (number of items)') . "</span>&nbsp;";
$out .= "<span class='responsive_hidden'>" . __s('Display (number of items)') . "</span>&nbsp;";
$out .= Dropdown::showListLimit("reloadTab(\"glpilist_limit=\"+this.value+\"$additional_params\")", false);
}
$out .= Html::closeForm(false);
Expand Down Expand Up @@ -5224,7 +5224,7 @@ public static function file($options = [])

if ($p['showtitle']) {
$display .= "<b>";
$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']
Expand Down

0 comments on commit 98cce0a

Please sign in to comment.