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

uriToFile: Ensure Linux relative paths are not mistaken for Windows network paths #379

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexandrumc
Copy link

No description provided.

return ret[1 .. $].replace("/", "\\");
else if (ret.length >= 1 && ret[0] != '/') // file://share windows path
return "\\\\" ~ ret.replace("/", "\\");
version(Windows) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess Jan wants a newline here for conformance.

@nordlow
Copy link
Contributor

nordlow commented Nov 19, 2024

CI breakage on Ubuntu at https://github.com/Pure-D/serve-d/actions/runs/11911163422/job/33192075621?pr=379#step:5:199.

It could be that those tests should be guarded behind a version(Windows) aswell.

@alexandrumc
Copy link
Author

alexandrumc commented Nov 19, 2024

CI breakage on Ubuntu at https://github.com/Pure-D/serve-d/actions/runs/11911163422/job/33192075621?pr=379#step:5:199.

I'm not sure what's wrong here.

It's exactly as I thought: relative paths are purposely not allowed. See: https://github.com/Pure-D/serve-d/pull/379/files#diff-5fe989f330d97e3213311a21f32b49f79da9362777f9213f9edcf25ae2935e62R21

@nordlow
Copy link
Contributor

nordlow commented Nov 19, 2024

It's exactly as I thought: relative paths are purposely not allowed. See: https://github.com/Pure-D/serve-d/pull/379/files#diff-5fe989f330d97e3213311a21f32b49f79da9362777f9213f9edcf25ae2935e62R21

There should be an in contract check for this, though.

@WebFreak001
Copy link
Member

relative paths should never come from an LSP implementation because the client can't assume the cwd of the server. The cwd that the client operates from might even be a virtual folder that doesn't have a filesystem equivalent. Usually you should avoid reading the files manually, since there are filesystem apis over JSON-RPC with LSP, but sometimes it's the only possible way to achieve certain things.

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

Successfully merging this pull request may close these issues.

3 participants