Skip to content

Only display http(s) URLs as links in HTML export #1568

Merged
Tyrrrz merged 1 commit into
Tyrrrz:primefrom
96-LB:patch-1
Jul 14, 2026
Merged

Only display http(s) URLs as links in HTML export #1568
Tyrrrz merged 1 commit into
Tyrrrz:primefrom
96-LB:patch-1

Conversation

@96-LB

@96-LB 96-LB commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread DiscordChatExporter.Core/Markdown/Parsing/MarkdownParser.cs
Comment thread DiscordChatExporter.Core/Markdown/Parsing/MarkdownParser.cs
@Tyrrrz
Tyrrrz merged commit 0358045 into Tyrrrz:prime Jul 14, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stored XSS in HTML exports through unrestricted masked-link schemes

3 participants