Skip to content

Links in markdown are broken if url contains encoded parameters #79474

Closed

Description

Issue Type: Bug

In the latest VSCode release (1.37.0) there seems to be a regression in markdown rendering feature, in that some of the URL parameters are incorrectly getting encoded .

Repro steps

  1. Create a markdown file and put following url content in it and save the file:
<!-- Begin markdown -->
[Sample Link](https://myhost.com/Redirect?url=http%3A%2F%2Fwww.bing.com%3Fsearch%3Dtom)
<!-- End markdown -->
  1. Click this link in markdown, see that the URL that is passed to browser is:

https://myhost.com/Redirect?url=http://www.bing.com%253Fsearch=tom

Notice that the %3F in the url parameter in the markdown link has been further encoded into %253F

Expected:
The URL that is passed to browser is either for the two below

  1. https://myhost.com/Redirect?url=http%3A%2F%2Fwww.bing.com%3Fsearch%3Dtom
  2. https://myhost.com/Redirect?url=http://www.bing.com?search=tom

This issue is true for other surfaces of markdown as well, like the 'Details' tab of installed extensions and the hover popup set through text decorations, via the vscode.DecorationOptions class.

This issue does not repro in older version of VSCode (1.36.0 and prior).

VS Code version: Code 1.37.1 (f06011a, 2019-08-15T16:17:55.855Z)
OS version: Windows_NT x64 10.0.18963

System Info
Item Value
CPUs Intel(R) Xeon(R) CPU E5-1650 v3 @ 3.50GHz (12 x 3492)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.91GB (0.57GB free)
Process Argv
Screen Reader no
VM 0%
Extensions (6)
Extension Author (truncated) Version
devinsights Mic 2019.1.25-6
vscode-nmake-tools Mic 2.0.190801001
cpptools ms- 0.24.1
powershell ms- 2019.5.0
vscode-typescript-tslint-plugin ms- 1.2.2
debugger-for-chrome msj 4.11.7

Activity

  1. added
    good first issue
    help wanted
    markdown-ext
    and removed on Aug 20, 2019
  2. rbrishabh commented on Aug 20, 2019

    @rbrishabh

    Hey! I would like to take this up! Could you please help me get started by pointing me to the directory (or file) where I should be making the changes?

    Thanks!

  3. hypercubestart commented on Aug 21, 2019

    @hypercubestart
    Contributor

    Matt Bierner (@mjbvz) pull request #79552 only fixes the hover popup, however I am not sure if preserving the query string is the best way to fix this issue

  4. removed
    good first issue
    help wanted
    on Aug 22, 2019
  5. jrieken commented on Aug 22, 2019

    @jrieken
    Contributor

    Sorry, this isn't a good first issue because it's a bit of a bottom-less whole.

    Matt Bierner (@mjbvz) The underlying issue is that Uri.parse decodes its input and then re-encodes when calling toString. That (re)encoding is needed because toString is mostly used to create comparable strings for storing things in maps, toString isn't primarily designed to create externalised uri-strings for exchange.

    Let's come up with a fix together. An idea that's worth exploring is to use uri.with, e.g start with "some" uri and then transform it into the uri you want. However, that requires that you are able to break the uri into its components...

  6. added
    bug
    on Oct 7, 2019
  7. jrieken commented on Oct 24, 2019

    @jrieken
    Contributor

    fixed via #83060

  8. jrieken commented on Oct 30, 2019

    @jrieken
    Contributor

    re-opened via 58479e8

  9. jrieken commented on Oct 30, 2019

    @jrieken
    Contributor

    /duplicate of #83645

    Closing this as a duplicate of #83645 which is all about finding a way out of the URI nightmare.

  10. added
    *duplicate
    on Oct 30, 2019
  11. vscodebot commented on Oct 30, 2019

    @vscodebot

    Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for existing issues here. See also our issue reporting guidelines.

    Happy Coding!

  12. locked and limited conversation to collaborators on Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

*duplicatebugmarkdown-exturiwebview

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions