Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better HTML encoding for DbUtils, DisplayPreference and DocumentType #17870

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/DbUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -1476,14 +1476,14 @@ public function getTreeValueCompleteName($table, $ID, $withcomment = false, $tra
$alias = $result['alias'];
if (!empty($alias)) {
$name = $alias;
$comment .= "<span class='b'>" . __('Alias:') . "</span> " . $alias . "<br/>";
$comment .= "<span class='b'>" . __s('Alias:') . "</span> " . htmlspecialchars($alias) . "<br/>";
}
if (!empty($code)) {
$name .= ' - ' . $code;
$comment .= "<span class='b'>" . __('Code:') . "</span> " . $code . "<br/>";
$comment .= "<span class='b'>" . __s('Code:') . "</span> " . htmlspecialchars($code) . "<br/>";
}
if (!empty($address)) {
$acomment .= $address;
$acomment .= htmlspecialchars($address);
}
if (
!empty($address) &&
Expand All @@ -1492,19 +1492,19 @@ public function getTreeValueCompleteName($table, $ID, $withcomment = false, $tra
$acomment .= '<br/>';
}
if (!empty($town)) {
$acomment .= $town;
$acomment .= htmlspecialchars($town);
}
if (!empty($country)) {
if (!empty($town)) {
$acomment .= ' - ';
}
$acomment .= $country;
$acomment .= htmlspecialchars($country);
}
if (trim($acomment) != '') {
$comment .= "<span class='b'>&nbsp;" . __('Address:') . "</span> " . $acomment . "<br/>";
$comment .= "<span class='b'>&nbsp;" . __s('Address:') . "</span> " . $acomment . "<br/>";
AdrienClairembault marked this conversation as resolved.
Show resolved Hide resolved
}
}
$comment .= "<span class='b'>&nbsp;" . __('Comments') . "&nbsp;</span>";
$comment .= "<span class='b'>&nbsp;" . __s('Comments') . "&nbsp;</span>";
}
$transcomment = $result['transcomment'];
if ($translate && !empty($transcomment)) {
Expand Down
4 changes: 2 additions & 2 deletions src/DisplayPreference.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public static function showMassiveActionsSubForm(MassiveAction $ma)
{
switch ($ma->getAction()) {
case 'reset_to_default':
$msg = __('This will reset the columns to the defaults for a new installation.');
$msg2 = __('This will only work for types from GLPI itself or enabled plugins that support this action.');
$msg = __s('This will reset the columns to the defaults for a new installation.');
$msg2 = __s('This will only work for types from GLPI itself or enabled plugins that support this action.');
echo '<div class="alert alert-info">' . $msg . '<br>' . $msg2 . '</div>';
echo Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']);
return true;
Expand Down
5 changes: 3 additions & 2 deletions src/DocumentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static function getSpecificValueToDisplay($field, $values, array $options
case 'icon':
if (!empty($values[$field])) {
return "&nbsp;<img style='vertical-align:middle;' alt='' src='" .
$CFG_GLPI["typedoc_icon_dir"] . "/" . $values[$field] . "'>";
htmlspecialchars($CFG_GLPI["typedoc_icon_dir"] . "/" . $values[$field]) . "'>";
}
}
return parent::getSpecificValueToDisplay($field, $values, $options);
Expand Down Expand Up @@ -191,7 +191,8 @@ public static function showAvailableTypesLink($options = [])
$display .= Ajax::createIframeModalWindow(
"documenttypelist_{$p['rand']}",
$CFG_GLPI["root_doc"] . "/front/documenttype.list.php",
['title' => static::getTypeName(Session::getPluralNumber()),
[
'title' => static::getTypeName(Session::getPluralNumber()),
'display' => false
]
);
Expand Down