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

Colons in windows drive letters are over-encoded in file URIs #1280

Closed
DanTup opened this issue Jul 21, 2023 · 4 comments
Closed

Colons in windows drive letters are over-encoded in file URIs #1280

DanTup opened this issue Jul 21, 2023 · 4 comments

Comments

@DanTup
Copy link
Contributor

DanTup commented Jul 21, 2023

The LSP client appears to send file URIs with over-encoded colons:

file:///C%3A/Dev/Test%20Projects/dart_application_3

I think this happens because VS Code's own URI class is doing this and it's just being used here:

https://github.com/microsoft/vscode-languageserver-node/blob/f2ff7d55464a1f58f978cb6635bd8865f050553c/client/src/common/codeConverter.ts#L154C62-L154C62

In Dart, I found that some first-party libraries handle this, and some do not. I've been trying to figure out whether it's valid or not (eg. whether the bug is VS Code/here, or in Dart) but the closest I've found to anything definitive is here:

https://url.spec.whatwg.org/#windows-drive-letter

A Windows drive letter is two code points, of which the first is an ASCII alpha and the second is either U+003A (:) or U+007C (|).

A string starts with a Windows drive letter if all of the following are true:

  • its length is greater than or equal to 2
  • its first two code points are a Windows drive letter
  • its length is 2 or its third code point is U+002F (/), U+005C (), U+003F (?), or U+0023 (#).

It also does not include a colon in the "path percent encode set" (only in the userinfo encode set), although it's not to me whether that forbids encoding it.

@dbaeumer
Copy link
Member

dbaeumer commented Aug 7, 2023

If I remember the discussion we had about this correctly there is no specification how this should be done when encoding drive letters and having %3A is equally correct. And VS Code will not change this due to the huge impact this has.

Since I know this can be difficult for server the VS Code client offers a way to intercept all URI -> string conversions and vice versa. So if you want to change how they are send over the wire the best I can suggest is to use that capability. See

@dbaeumer dbaeumer closed this as completed Aug 7, 2023
@DanTup
Copy link
Contributor Author

DanTup commented Aug 7, 2023

@dbaeumer that's what I've ended up doing for now - but that is VS Code specific and the goal is for the LSP server to work with all clients (and similarly, clients to work with all servers).

Is your opinion that a) all servers should handle encoded colons, or b) that clients should not send encoded colons (and VS Code extensions should fix up the URI)? I think it would be beneficial to note this one way or the other in the spec so it's clear who should fix any incompatibilities that arise from this.

I'm happy to send a PR that adds a note somewhere if you can confirm which direction you'd prefer it went. Thanks!

@dbaeumer
Copy link
Member

dbaeumer commented Aug 8, 2023

IMO a server needs to handle all valid encoded URLs. I am not a fan of specing how URLs should be encoded in LSP.

Add a note to the specification makes total sense to me.

@DanTup
Copy link
Contributor Author

DanTup commented Aug 8, 2023

Thanks - I opened microsoft/language-server-protocol#1786 - happy to tweak/rewrite as you'd prefer!

dbaeumer added a commit to microsoft/language-server-protocol that referenced this issue Oct 19, 2023
* Add an explicit note about drive letter colons

See microsoft/vscode-languageserver-node#1280

* Tweak text

* Add a note about drive letter casing

---------

Co-authored-by: Dirk Bäumer <dirkb@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants