lemmy icon indicating copy to clipboard operation
lemmy copied to clipboard

Code block containing URL gets corrupted

Open KaKi87 opened this issue 7 months ago • 2 comments

Requirements

  • [x] This is a bug report, and if not, please post to https://lemmy.ml/c/lemmy_support instead.
  • [x] Please check to see if this issue already exists.
  • [x] It's a single bug. Do not report multiple bugs in one issue.
  • [x] It's a frontend issue, not a backend issue; Otherwise please create an issue on the backend repo instead.

Summary

Submitting a post or comment on Lemmy with the following :

```javascript
const url = `https://example.com?foo=${bar}`
```

Gets turned into the following :

```javascript
const url = `https://example.com/?foo=%24%7Bbar%7D`
```

Diff :

Steps to Reproduce

  1. Write this code block as a post or comment ;
  2. Submit ;
  3. Notice difference.

Technical Details

Not relevant

Lemmy Instance Version

0.19.12

Lemmy Instance URL

https://jlai.lu/comment/15092350

KaKi87 avatar Jun 17 '25 17:06 KaKi87

Confirmed

Nutomic avatar Jul 29 '25 09:07 Nutomic

This problem is caused by the url cleaner added in https://github.com/LemmyNet/lemmy/pull/5018. It needs to ignore text inside of code blocks, probably by converting it to a markdown-it plugin and working similar to markdown_rewrite_image_links().

Nutomic avatar Sep 10 '25 14:09 Nutomic