Skip to content

Commit

Permalink
FIX Escape user input from an HTML context.
Browse files Browse the repository at this point in the history
There is no XSS vulnerability here due to other measures to mitigate one
- but user input which includes HTML characters still might not render
  correctly without this fix.
  • Loading branch information
GuySartorelli committed Jan 14, 2025
1 parent 2ade8aa commit 8e9b9e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/RestoreAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace SilverStripe\Versioned;

use SilverStripe\Core\Convert;
use SilverStripe\ORM\Hierarchy\Hierarchy;
use SilverStripe\ORM\ValidationException;
use SilverStripe\Versioned\Versioned;
Expand Down Expand Up @@ -86,7 +87,7 @@ public static function restore($item)
public static function getRestoreMessage($originalItem, $restoredItem, $changedLocation = false)
{
$restoredID = $restoredItem->Title ?: $restoredItem->ID;
$restoredType = strtolower($restoredItem->i18n_singular_name() ?? '');
$restoredType = Convert::raw2xml(strtolower($restoredItem->i18n_singular_name() ?? ''));

if (method_exists($restoredItem, 'CMSEditLink') &&
$restoredItem->CMSEditLink()) {
Expand Down
10 changes: 5 additions & 5 deletions src/VersionedGridFieldItemRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ public function doArchive($data, $form)
__CLASS__ . '.Archived',
'Archived {name} "{title}"',
[
'name' => $record->i18n_singular_name(),
'title' => $title
'name' => Convert::raw2xml($record->i18n_singular_name()),
'title' => Convert::raw2xml($title)
]
);
$this->setFormMessage($form, $message);
Expand Down Expand Up @@ -174,7 +174,7 @@ public function doPublish($data, $form)
__CLASS__ . '.Published',
'Published {name} {link}',
[
'name' => $record->i18n_singular_name(),
'name' => Convert::raw2xml($record->i18n_singular_name()),
'link' => $link
]
);
Expand Down Expand Up @@ -218,8 +218,8 @@ public function doUnpublish($data, $form)
__CLASS__ . '.Unpublished',
'Unpublished {name} "{title}"',
[
'name' => $record->i18n_singular_name(),
'title' => $title
'name' => Convert::raw2xml($record->i18n_singular_name()),
'title' => Convert::raw2xml($title)
]
);
$this->setFormMessage($form, $message);
Expand Down

0 comments on commit 8e9b9e3

Please sign in to comment.