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

Escape Unsafe HTML Characters in addon-serialize #5020

Merged
merged 3 commits into from Apr 21, 2024

Conversation

sawka
Copy link
Contributor

@sawka sawka commented Mar 29, 2024

I was testing the addon-serialize serializeAsHTML functionality and noticed that it can produce invalid/unsafe html because it isn't escaping "<" and "&" characters in the output spans. Wrote a quick patch that escapes those two dangerous characters in the output.

Note that a lot of functions/libraries want to escape other characters (like quotes, greater than, etc.). These are only necessary to escape unless you are also worried about attribute values. These characters do not need to be escaped when you are only dealing with characters between tags (text content) which is the case here.

I added a test (which passes), but didn't put the more canonical "<script>alert("hello")</script>" test in because the test terminal only has 10 columns. All of the other serialize tests continue to pass.

@Tyriar Tyriar added this to the 5.6.0 milestone Apr 21, 2024
@Tyriar Tyriar self-assigned this Apr 21, 2024
@Tyriar Tyriar merged commit 1709d44 into xtermjs:master Apr 21, 2024
16 checks passed
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.

None yet

2 participants