Skip to content

fix-click-chat-messege - #305

Open
Sayan-pixel wants to merge 2 commits into
Vault-Web:mainfrom
Sayan-pixel:fix-clickable-urls
Open

fix-click-chat-messege#305
Sayan-pixel wants to merge 2 commits into
Vault-Web:mainfrom
Sayan-pixel:fix-clickable-urls

Conversation

@Sayan-pixel

Copy link
Copy Markdown

Summary

Implemented support for clickable URLs in chat messages.

  • Detects only http:// and https:// URLs in decrypted chat messages.
  • Converts detected URLs into clickable links.
  • Escapes all non-URL text before rendering to prevent HTML injection.
  • Opens links in a new tab using target="_blank".
  • Adds rel="noopener noreferrer" for improved security.
  • Sanitizes the generated HTML before binding it to the template.
  • Keeps all non-URL message content as plain text.

Linked issue

Closes #302

How to test

  1. Start the frontend.
  2. Open a private chat.
  3. Send the following messages:
    • Hello World
    • https://google.com
    • Visit https://github.com/Vault-Web
    • https://google.com https://openai.com
    • ftp://example.com
    • <script>alert(1)</script>
  4. Verify:
    • Only http:// and https:// URLs are clickable.
    • Links open in a new tab.
    • All other text remains plain text.
    • HTML/script tags are displayed as text and are not executed.

Notes / Risk

  • The change is limited to plain URL detection as described in the issue.
  • Markdown and arbitrary HTML rendering are intentionally not supported to minimize the attack surface.
  • The generated HTML is sanitized before rendering for additional protection against XSS.

@DenizAltunkapan

Copy link
Copy Markdown
Member

@Sayan-pixel please fix the failing workflows

@Sayan-pixel
Sayan-pixel deleted the fix-clickable-urls branch July 31, 2026 17:47
@Sayan-pixel
Sayan-pixel restored the fix-clickable-urls branch July 31, 2026 17:48
@Sayan-pixel Sayan-pixel reopened this Jul 31, 2026
- Replace {{ msg.content }} interpolation with [innerHTML] binding
- Add formatMessage() that detects URLs and wraps them in <a> tags
- Escape all text segments with escapeHtml() to prevent XSS
- Escape URLs in href attribute to prevent attribute breakout
- Strip trailing punctuation (.,;:!?) from matched URLs
- Sanitise assembled HTML with DOMPurify (ADD_ATTR: ['target'])
- Set target=_blank and rel='noopener noreferrer' on generated links
- Add scoped ::ng-deep styles for links inside chat bubbles
- Add 8 unit tests covering linkification, XSS, edge cases

Closes #<issue-number>
@Sayan-pixel

Copy link
Copy Markdown
Author

Summary

URLs sent in chat messages are now rendered as clickable links that open in a new tab. Only http:// and https:// schemes are linkified — everything else stays as plain text. No full Markdown or HTML parsing is introduced.

Problem

The message bubble rendered decrypted content using Angular interpolation ({{ msg.content }}), which escapes the value into plain text. Recipients had to manually select and copy URLs to visit them.

Solution

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.

URLs in chat messages are not clickable

2 participants