[Bug]: Pasted URL gets modified by Lemmy as it's being posted
Requirements
- Is this a bug report? For questions or discussions use https://lemmy.ml/c/lemmy_support or the matrix chat.
- Did you check to see if this issue already exists?
- Is this only a single bug? Do not put multiple bugs in one issue.
- Do you agree to follow the rules in our Code of Conduct?
- Is this a backend issue? Use the lemmy-ui repo for UI / frontend issues.
Summary
Discovered when it broke a link in this post: https://discuss.tchncs.de/post/64164280 / https://sopuli.xyz/post/48879464 / https://kbin.earth/m/[email protected]/t/2988865 (note: issue not present in kbin.earth link)
Encoded URLs get modified and broken after being posted. This even happens within inline code spans, and probably code blocks (not tested).
Demo: https://discuss.tchncs.de/post/64167722 / https://lemmy.ml/post/50172294
Authoring source:
Authoring preview:
Posted result:
Editing after posting:
Steps to Reproduce
- Post a comment or text post with the following text:
The following links should all have the query string `?P=5%B02%27`.
`example.com/query?P=5%B02%27`
example.com/query?P=5%B02%27
[link](example.com/query?P=5%B02%27)
`www.example.com/query?P=5%B02%27`
www.example.com/query?P=5%B02%27
[link](www.example.com/query?P=5%B02%27)
`http://www.example.com/query?P=5%B02%27`
http://www.example.com/query?P=5%B02%27
[link](http://www.example.com/query?P=5%B02%27)
`https://www.example.com/query?P=5%B02%27`
https://www.example.com/query?P=5%B02%27
[link](https://www.example.com/query?P=5%B02%27)- View the resulting post and notice that all URLs with a protocol (
http:orhttps:) irreversibly changed from5%B02%27to5%EF%BF%BD2%27
Technical Details
Besides the obviously bad code, I'll note something else: a post's source, what shows up when clicking 'Edit' after posting, should always be identical to the post as it was submitted. Any modifications made to it (smart quotes, emoticons to emoji, or whatever other random fancy features you want to add) should never overwrite the original source and make it irrecoverable.
Version
BE: 0.19.19
Lemmy Instance URL
discuss.tchncs.de, sopuli.xyz
Source: LemmyNet/lemmy