Skip to content

fix: lsp panics when processing paths containing %#223

Closed
codesuki wants to merge 6 commits intogolang:masterfrom
codesuki:patch-1
Closed

fix: lsp panics when processing paths containing %#223
codesuki wants to merge 6 commits intogolang:masterfrom
codesuki:patch-1

Conversation

@codesuki
Copy link

Bazel uses % in its temporary paths which is not a valid URI.
Therefore url.PathUnescape will panic.
See golang/go#37984

Bazel uses % in its temporary paths which is not a valid URI. 
Therefore url.PathUnescape will panic.
See golang/go#37984
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@codesuki
Copy link
Author

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@gopherbot
Copy link
Contributor

This PR (HEAD: 81f0ca7) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/228640 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Gobot Gobot:

Patch Set 1:

Congratulations on opening your first change. Thank you for your contribution!

Next steps:
Within the next week or so, a maintainer will review your change and provide
feedback. See https://golang.org/doc/contribute.html#review for more info and
tips to get your patch through code review.

Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.

During May-July and Nov-Jan the Go project is in a code freeze, during which
little code gets reviewed or merged. If a reviewer responds with a comment like
R=go1.11, it means that this CL will be reviewed as part of the next development
cycle. See https://golang.org/s/release for more details.


Please don’t reply on this GitHub thread. Visit golang.org/cl/228640.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

This PR (HEAD: e85b4cb) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/228640 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

This PR (HEAD: 612ea11) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/228640 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

This PR (HEAD: 1cc03be) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/228640 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

This PR (HEAD: ebf74c5) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/228640 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

This PR (HEAD: 4d34305) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/tools/+/228640 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link
Contributor

Message from Neri Marschik:

Patch Set 6:

Hi, more context below.

Emacs lsp-mode uses the the function url-hexify-string to convert a path to an URI.
Following down the rabbit hole you find this line
;; Allow % to avoid re-encoding %-encoded sequences.
https://github.com/emacs-mirror/emacs/blob/master/lisp/url/url-util.el#L415

The following PR would solve the issue I think, but it breaks with emacs < 26.x
emacs-lsp/lsp-mode#1089

This PR to gopls then broke it.
f8e42dc

Questionable whether or not this should be fixed in gopls, but it makes gopls useless for emacs users.
Also there is prior art here, fixing gopls for visual studio code.


Please don’t reply on this GitHub thread. Visit golang.org/cl/228640.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Rebecca Stambler:

Patch Set 6:

Patch Set 6:

Hi, more context below.

Emacs lsp-mode uses the the function url-hexify-string to convert a path to an URI.
Following down the rabbit hole you find this line
;; Allow % to avoid re-encoding %-encoded sequences.
https://github.com/emacs-mirror/emacs/blob/master/lisp/url/url-util.el#L415

The following PR would solve the issue I think, but it breaks with emacs < 26.x
emacs-lsp/lsp-mode#1089

This PR to gopls then broke it.
f8e42dc

Questionable whether or not this should be fixed in gopls, but it makes gopls useless for emacs users.
Also there is prior art here, fixing gopls for visual studio code.

Thank you for the thorough explanation and contribution!

However, it seems to me that it's the responsibility of Emacs to create a valid URI that gets sent to gopls. We have worked around VS Code in the past, but we want to avoid overfitting to specific clients. Also, VS Code over escapes, whereas here, it seems like Emacs is sending incorrectly escaped URIs.

I'll let Heschi make the final decision here, but it seems to me like the PR that fixes the issue in Emacs is the right approach. It's unfortunate that it requires a later version of Emacs, but maybe that can still be handled.


Please don’t reply on this GitHub thread. Visit golang.org/cl/228640.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Neri Marschik:

Patch Set 6:

However, it seems to me that it's the responsibility of Emacs to create a valid URI that gets sent to gopls. We have worked around VS Code in the past, but we want to avoid overfitting to specific clients. Also, VS Code over escapes, whereas here, it seems like Emacs is sending incorrectly escaped URIs.
Totally agree. Unfortunately I did the root cause analysis after submitting this patch :)
I didn't know how LSP works, at all, so never thought this was an emacs problem.
I submitted a patch there: emacs-lsp/lsp-mode#1593


Please don’t reply on this GitHub thread. Visit golang.org/cl/228640.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link
Contributor

Message from Rebecca Stambler:

Patch Set 6:

Patch Set 6:

However, it seems to me that it's the responsibility of Emacs to create a valid URI that gets sent to gopls. We have worked around VS Code in the past, but we want to avoid overfitting to specific clients. Also, VS Code over escapes, whereas here, it seems like Emacs is sending incorrectly escaped URIs.
Totally agree. Unfortunately I did the root cause analysis after submitting this patch :)
I didn't know how LSP works, at all, so never thought this was an emacs problem.
I submitted a patch there: emacs-lsp/lsp-mode#1593

Wonderful - thank you so much for doing this work!


Please don’t reply on this GitHub thread. Visit golang.org/cl/228640.
After addressing review feedback, remember to publish your drafts!

@codesuki
Copy link
Author

This is merged in emacs lsp-mode now. emacs-lsp/lsp-mode#1593

@codesuki codesuki closed this Apr 20, 2020
@codesuki codesuki deleted the patch-1 branch April 20, 2020 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants