OmniSharp / OmniSharp/csharp-language-server-protocol

Should `%` in `DocumentUri.Path` be encoded in `DocumentUri.ToUri()`?

Open
#1,005 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
638
Forks
109
Avg merge
1m
Merged PRs (30d)
2

Description

DocumentUri.ToUri() produces identical Uris for different file paths:

var filePath1 = @"c:/foo bar/test#.txt";
var filePath2 = @"c:/foo%20bar/test%23.txt";

DocumentUri documentUri1 = DocumentUri.FromFileSystemPath(filePath1);
DocumentUri documentUri2 = DocumentUri.FromFileSystemPath(filePath2);

Console.WriteLine(documentUri1.Path); // /c:/foo bar/test#.txt
Console.WriteLine(documentUri2.Path); // /c:/foo%20bar/test%23.txt

var uri1 = documentUri1.ToUri();
var uri2 = documentUri2.ToUri();

Console.WriteLine(uri1); // file:///c:/foo bar/test%23.txt
Console.WriteLine(uri2); // file:///c:/foo bar/test%23.txt

Can anyone confirm if this is by design or a bug? If it's a bug, I think the fix would be to encode % in DocumentUri.Path before assigning it to UriBuilder.Path in DocumentUri.ToUri().

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at DocumentUri.ToUri(), tracing how DocumentUri.Path is assigned to UriBuilder.Path, and compare the two paths and resulting URIs shown in the report. Confirm the intended percent-encoding behavior; done means the two distinct source paths no longer produce identical URIs.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.