Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uri doesn't honour http-specialities #31805

Closed
defr0std opened this issue Aug 1, 2017 · 3 comments
Closed

Uri doesn't honour http-specialities #31805

defr0std opened this issue Aug 1, 2017 · 3 comments
Assignees
Labels
feature-request Request for new features or functionality uri

Comments

@defr0std
Copy link

defr0std commented Aug 1, 2017

  • VSCode Version: 1.14.2
  • OS Version: any

Steps to Reproduce:

  1. Create and MD file and paste the following link:
    https://azure.microsoft.com/en-us/?ru=https%3A%2F%2Fmicrosoft.com%2F%3Fparam1%3Dvalue1%26param2%3Dvalue2

  2. Preview and click on the link. You will be sent to https://azure.microsoft.com/en-us/?ru=https://microsoft.com/%3Fparam1=value1&param2=value2

Notice that the url parameter ru is an encoded link. VSCode decodes the parameter and the final link becomes incorrect. Just compare to how GitHub works when you click on the link in step 1.

Reproduces without extensions: Yes

@vscodebot vscodebot bot added the new release label Aug 1, 2017
@kieferrm kieferrm added the markdown Markdown support issues label Aug 1, 2017
@mjbvz
Copy link
Collaborator

mjbvz commented Aug 1, 2017

I don't think this is markdown specific. I see the same behavior when clicking on that link in the editor. Root cause seems to be our Uri parsing logic:

URI.parse('https://azure.microsoft.com/en-us/?ru=https%3A%2F%2Fmicrosoft.com%2F%3Fparam1%3Dvalue1%26param2%3Dvalue2')

returns

https://azure.microsoft.com/en-us/?ru=https://microsoft.com/%3Fparam1=value1&param2=value2

Whereas

decodeURI('https://azure.microsoft.com/en-us/?ru=https%3A%2F%2Fmicrosoft.com%2F%3Fparam1%3Dvalue1%26param2%3Dvalue2')

returns

https://azure.microsoft.com/en-us/?ru=https%3A%2F%2Fmicrosoft.com%2F%3Fparam1%3Dvalue1%26param2%3Dvalue2

@jrieken
Copy link
Member

jrieken commented Aug 14, 2017

Root cause seems to be our Uri parsing logic:

The parsing logic doesn't return a string as that comment suggests but simply parses an input string into URI components (scheme, auth, path, query, fragment). The toString-method does percent encoding everything (without looking at the scheme for more specialised encoding tricks). When called with false the toString-method does only encode & and ? because those are needed to parse it again.

Assuming that the result of toString can always be used in http or any other specialised protocol is not correct.

@jrieken jrieken added feature-request Request for new features or functionality workbench labels Aug 14, 2017
@jrieken jrieken changed the title Markdown links incorrectly parsed Uri doesn't honour http-specialities Aug 14, 2017
@jrieken jrieken added uri and removed workbench labels Oct 30, 2017
@jrieken
Copy link
Member

jrieken commented Oct 30, 2017

dupe of #25852

@jrieken jrieken closed this as completed Oct 30, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality uri
Projects
None yet
Development

No branches or pull requests

5 participants