Skip to content

Commit

Permalink
Fix code scanning alert #520: Client-side cross-site scripting
Browse files Browse the repository at this point in the history
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 2e53df6 commit 32c6ab1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"devDependencies": {
"eslint": "^9.10.0"
},
"dependencies": {
"dompurify": "^3.1.6"
}
}
8 changes: 5 additions & 3 deletions server-data/resources/[esx_addons]/esx_garage/nui/js/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import DOMPurify from 'dompurify';

$(window).ready(function() {
window.addEventListener('message', function(event) {
const data = event.data;
Expand Down Expand Up @@ -52,13 +54,13 @@ $(window).ready(function() {
}

$('.vehicle-listing').html(function(_i, text) {
return text.replace('Model', data.locales.veh_model);
return text.replace('Model', DOMPurify.sanitize(data.locales.veh_model));
});
$('.vehicle-listing').html(function(_i, text) {
return text.replace('Plate', data.locales.veh_plate);
return text.replace('Plate', DOMPurify.sanitize(data.locales.veh_plate));
});
$('.vehicle-listing').html(function(_i, text) {
return text.replace('Condition', data.locales.veh_condition);
return text.replace('Condition', DOMPurify.sanitize(data.locales.veh_condition));
});
}
else if (data.hideAll) {
Expand Down

0 comments on commit 32c6ab1

Please sign in to comment.