Markdown URL with text fragment falsely decoded when opening with ctrl + click in editor
#245,128 opened on Mar 31, 2025
Repository metrics
- Stars
- (74,848 stars)
- PR merge metrics
- (Avg merge 11h 43m) (1,000 merged PRs in 30d)
Description
Found some more edge cases for #83645 (and related).
To verify
have it inside an editor and click on it from the editor (not markdown)
have it in a markdown-file and click on it from the markdown preview
have it as jsdoc-markdown hover and click on it from there
have it in the terminal (echo ...) and click on it from there
in ALL cases it should show a loaf of bread
Originally posted by @jrieken in #83645
I tested the following markdown in a new window with code --disable-extensions and Restricted Mode so URLs are shown before opening them in the browser.


[test](https://firebasestorage.googleapis.com/v0/b/brewlangerie.appspot.com/o/products%2FzVNZkudXJyq8bPGTXUxx%2FBetterave-Sesame.jpg?alt=media&token=0b2310c4-3ea6-4207-bbde-9c3710ba0437)
[test](https://firebasestorage.googleapis.com/v0/b/brewlangerie.appspot.com/o/products%2FzVNZkudXJyq8bPGTXUxx%2FBetterave-Sesame.jpg?alt=media&token=0b2310c4-3ea6-4207-bbde-9c3710ba0437 "test")
<https://firebasestorage.googleapis.com/v0/b/brewlangerie.appspot.com/o/products%2FzVNZkudXJyq8bPGTXUxx%2FBetterave-Sesame.jpg?alt=media&token=0b2310c4-3ea6-4207-bbde-9c3710ba0437>
[test][def]
[def]: https://firebasestorage.googleapis.com/v0/b/brewlangerie.appspot.com/o/products%2FzVNZkudXJyq8bPGTXUxx%2FBetterave-Sesame.jpg?alt=media&token=0b2310c4-3ea6-4207-bbde-9c3710ba0437
```markdown


[test](https://firebasestorage.googleapis.com/v0/b/brewlangerie.appspot.com/o/products%2FzVNZkudXJyq8bPGTXUxx%2FBetterave-Sesame.jpg?alt=media&token=0b2310c4-3ea6-4207-bbde-9c3710ba0437)
[test](https://firebasestorage.googleapis.com/v0/b/brewlangerie.appspot.com/o/products%2FzVNZkudXJyq8bPGTXUxx%2FBetterave-Sesame.jpg?alt=media&token=0b2310c4-3ea6-4207-bbde-9c3710ba0437 "test")
<https://firebasestorage.googleapis.com/v0/b/brewlangerie.appspot.com/o/products%2FzVNZkudXJyq8bPGTXUxx%2FBetterave-Sesame.jpg?alt=media&token=0b2310c4-3ea6-4207-bbde-9c3710ba0437>
[test][def]
[def]: https://firebasestorage.googleapis.com/v0/b/brewlangerie.appspot.com/o/products%2FzVNZkudXJyq8bPGTXUxx%2FBetterave-Sesame.jpg?alt=media&token=0b2310c4-3ea6-4207-bbde-9c3710ba0437
```
When clicking (via ctrl+click) on all links, some don't work:
- hovering over the links shows a broken image (like:
), since it falsely links to https://firebasestorage.googleapis.com/v0/b/brewlangerie.appspot.com/o/products/zVNZkudXJyq8bPGTXUxx/Betterave-Sesame.jpg?alt%3Dmedia%26token%3D0b2310c4-3ea6-4207-bbde-9c3710ba0437- except within the inner code block, which shows nothing on hover (other than "Follow link (ctrl + click)")
- all (except
<...>/all within the inner code block/all in the preview) don't work and falsely decode the URL on opening:- to
https://firebasestorage.googleapis.com/v0/b/brewlangerie.appspot.com/o/products/zVNZkudXJyq8bPGTXUxx/Betterave-Sesame.jpg?alt=media&token=0b2310c4-3ea6-4207-bbde-9c3710ba0437
- to
I initially noticed this with the URL https://ffmpeg.org/ffmpeg-all.html#:~:text=%2Dversion, which falsely decodes the %2D in the text fragment (so it doesn't highlight the first -version on the page, which it should), which I thought was the root problem, but turns out that generally the URI/URL parsing was problematic for a long time...
For the edge case specific to the text fragment ~ any
%2Dafter:~:, which is after#, should stay percent encoded (among others, see specs linked below).
Anyway, here is another test with more problems:
[test](https://ffmpeg.org/ffmpeg-all.html?test=a%23b%20c#:~:text=%2Dversion)
[test](https://ffmpeg.org/ffmpeg-all.html?test=a%23b%20c#:~:text=%2Dversion "test")
<https://ffmpeg.org/ffmpeg-all.html?test=a%23b%20c#:~:text=%2Dversion>
[test][def]
[def]: https://ffmpeg.org/ffmpeg-all.html?test=a%23b%20c#:~:text=%2Dversion
```markdown
[test](https://ffmpeg.org/ffmpeg-all.html?test=a%23b%20c#:~:text=%2Dversion)
[test](https://ffmpeg.org/ffmpeg-all.html?test=a%23b%20c#:~:text=%2Dversion "test")
<https://ffmpeg.org/ffmpeg-all.html?test=a%23b%20c#:~:text=%2Dversion>
[test][def]
[def]: https://ffmpeg.org/ffmpeg-all.html?test=a%23b%20c#:~:text=%2Dversion
```
- In the markdown preview, all work but the
<...>shows some characters decoded (but still links correctly)- shows as
https://ffmpeg.org/ffmpeg-all.html?test=a%23b c#:~:text=-version
- shows as
- just as before, all (except the
<...>/all within the inner code block/all in the preview) fail:- warning shows
https://ffmpeg.org/ffmpeg-all.html?test=a#b c#:~:text=-version - copy from warning gives
https://ffmpeg.org/ffmpeg-all.html?test=a%23b c#:~:text=-version - opens
https://ffmpeg.org/ffmpeg-all.html?test=a%2523b%20c#:~:text=-versionin the browser
- warning shows