Only display http(s) URLs as links in HTML export #1568
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR mitigates the stored XSS risk in HTML exports by tightening Discord-style masked-link ([title](link)) parsing so that only http:// and https:// targets are treated as links, matching Discord’s behavior for non-whitelisted schemes.
Changes:
- Restricts the masked-link URL capture regex to
http(s)://...instead of any arbitrary scheme/value. - Aligns masked-link URL matching behavior with the existing auto-link URL pattern rules (e.g., avoiding trailing punctuation).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #1567.
The masked link regex (for links of the type
[title](link)) was too broad, leading to the possibility of XSS attacks as described in #1567. Discord itself displays these links as plaintext instead of formatting them as markdown, so this PR updates the regex to only match http and https links.Note: Discord also turns a few other schemes into links (from my testing, this includes mailto, sms, tel, and discord), but DCE doesn't display these as links (except when masked), so I limited this PR to http and https for consistency.