Distinguish links converted from raw text and made using formatting

AI 生成的摘要

The discussion explores the challenge of distinguishing between links automatically converted from raw text and those manually formatted in Discourse posts, highlighting potential security risks and user confusion. jooize raises concern that raw text links (e.g., https://discourse.org) can be misleading and potentially malicious, suggesting visual cues like underlining to differentiate them from properly formatted links. pfaffman notes that mouse-over tooltips already provide a standard way to check link destinations. jooize emphasizes the need for clarity, especially in communities where trust is crucial. codinghorror references an existing plugin for external link warnings, favoring Google Safe Browsing over blanket alerts. jooize acknowledges the complexity of detecting all workarounds but suggests focusing on links with URL schemes. Mittineague proposes a JavaScript solution to visually distinguish links where the displayed text differs from the URL, offering a proof-of-concept using CSS styling.

Links can be misleading and potentially an attack vector.

https://discourse.org

That links goes to meta.discourse.org, but you wouldn’t know without checking first.

Discourse could indicate when a link is converted from raw text as the second link or made using formatting as the first. I have not considered how to do that. Perhaps underdotting for raw text links, or the other way around.

There’s the idea anyhow.

1 个赞

This is true for every link on the web. You can mouse-over a link to see where it’s going to go.

3 个赞

Yes, of course, but we can mostly avoid the issue in every Discourse forum. Trust remains in the administrators. I’m saying it might be worthwhile to resolve the issue with all regular posters.

There is an existing discussion on a plugin to warn on all external links (not a fan) or warn on known bad links as vetted by google safe browsing service — which is a much better idea.

I don’t want to clutter the interface too much either. Working with cryptocurrencies where a wallet was found to be reachable by any website via JavaScript made me think of this. Known bad links will always lag behind.

If only formatted links including an url scheme would be indicated as possibly misleading, but it’s probably a rabbit hole of targetting all creative workarounds.

Cheers

If I’m understanding, you want to distinguish between

<a href="http://example.com">http://example.com</a> 
<a href="http://example.com">some text</a>

where the “some text” is not the href value.

I think a short amount of JavaScript working with the cooked could style them differently.

EDIT
As a proof of concept, this works for me on my localhost in Customize </body>

 $(document).on("ajaxComplete", function( event ) {
  let post_links = document.body.querySelectorAll(".contents .cooked a:not(.back):not(.mention)");
  let i = 0;
  for (i = 0; i < post_links.length; i++) {
      if ( post_links[i].href != post_links[i].textContent ) {
          post_links[i].style.outline = "1px solid #900";
      }
  }
});
6 个赞