-
-
Notifications
You must be signed in to change notification settings - Fork 490
Fix #374 and #409 - Prevent XSS and add Markdown support #448
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
Conversation
Note: I implemented prettier in the project, if you can please use it so we keep the code format consistent |
Hey @antoine92190, I've run prettier for the files changed in this PR. ✅ |
Also, happy to discuss the unified dependency and how it could play into Markdown support and #409. The goal is to simplify |
Fixes the XSS vulnerability by handling three different formatting modes we support separately.
A new helper
parse-message.js
was added toutils
that uses the popular battle-tested unified library with plugins for HTML and Markdown to sanitize and translate Markdown to HTML, adding full Markdown support.The default formatting mode no longer uses
v-html
to dynamically add arbitrary HTML to the DOM, however, users can still customize messages with dynamic HTML, opting in usingtext-formatting='{ "html": true }'
. The injected HTML is first sanitized to remove dangerous elements.text-formatting='{ "markdown": true }'
was similarly added to allow users to use CommonMark-compliant Markdown.The default formatting functions in
FormatMessage.vue
were refactored intoparse-message.js
to consolidate the parsing logic.Note these changes also set the groundwork to address #409.
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
fix #xxx[,#xxx]
, where "xxx" is the issue number)