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

It's still possible to disguise links as other links #1397

Open
ekzyis opened this issue Sep 12, 2024 · 0 comments
Open

It's still possible to disguise links as other links #1397

ekzyis opened this issue Sep 12, 2024 · 0 comments

Comments

@ekzyis
Copy link
Member

ekzyis commented Sep 12, 2024

Description

This code exists to avoid that one can write stacker.news which looks like it's a link to stacker.news but it's actually not (this works on Github too though).

// If [text](url) was parsed as <a> and text is not empty and not a link itself,
// we don't render it as an image since it was probably a conscious choice to include text.
const text = children[0]
let url
try {
url = !href.startsWith('/') && new URL(href)
} catch {
// ignore invalid URLs
}

Steps to Reproduce

  1. Write [stacker.news](https://www.youtube.com/watch?v=dQw4w9WgXcQ)
  2. Click preview
  3. See that it gets rendered as a link to stacker.news but it's a link to youtube.com

Expected behavior

It should refuse to use the text chosen by the user if it looks like it's pretending to be another link

Logs
If applicable, add your browsers console logs.

Environment:
If you only experience the issue on certain devices or browsers, provide that info.

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant