Skip to content

Fix: Escape HTML to Stop XSS Injection#7

Merged
sn merged 1 commit intosn:mainfrom
jknndy:Escape-HTML
Nov 8, 2025
Merged

Fix: Escape HTML to Stop XSS Injection#7
sn merged 1 commit intosn:mainfrom
jknndy:Escape-HTML

Conversation

@jknndy
Copy link
Contributor

@jknndy jknndy commented Nov 8, 2025

This patch fixes a security issue where user text and attributes weren’t escaped, allowing XSS (Cross-Site Scripting) injection.

Fix

  • Used html.escape() to sanitize text and attribute values.

Changes

  • Imported html
  • Escaped text: html.escape(self._text)
  • Escaped attributes: html.escape(str(v), quote=True)
  • Added tests confirming scripts are escaped and normal text still works

All tests passing.

@sn sn self-assigned this Nov 8, 2025
@sn sn merged commit 9464357 into sn:main Nov 8, 2025
5 checks passed
@sn
Copy link
Owner

sn commented Nov 8, 2025

Good catch, thanks @jknndy

@jknndy jknndy deleted the Escape-HTML branch November 8, 2025 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants