Potential fix for code scanning alert no. 1: DOM text reinterpreted as HTML #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Potential fix for https://github.com/GrimbiXcode/mtgscan/security/code-scanning/1
To fix the problem, escape any untrusted text content before inserting it into
innerHTML. Specifically, for the notification system, instead of interpolating the user-providedmessage(which could contain HTML) directly into the notification's innerHTML, you should either:messagestring (convert<,>,&,",'etc. to their HTML entity equivalents), ORtextContentinstead of innerHTML for the message part.The best approach in this context is to set
.innerHTMLonly for safe, static markup (like the icon and structure), and inject the user-providedmessageas plain text usingtextContent.This means:
showNotification, change the logic so that the notification container is constructed as a DOM structure withcreateElement, then set the icon via innerHTML (as it's from a hardcoded set), and set the message viatextContent.messagetext before interpolation.The edits are needed in
showNotification(lines 2305-2309). If escaping is used, a smallescapeHtmlmethod will be required in the class.Suggested fixes powered by Copilot Autofix. Review carefully before merging.