Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Handle escaped colons in Windows file:// URIs #149

Merged
merged 2 commits into from
Aug 9, 2023

Conversation

DanTup
Copy link
Contributor

@DanTup DanTup commented Aug 8, 2023

This is a potential fix for dart-lang/core#545. Using Uri().toFilePath() handles escaped colons in drive letters, but Context.fromUri() currently (without this PR) does not.

I'm unable to find anything concrete about how valid this is, but the opinion of the LSP maintainers is that this is valid, and since the Uri class handles it I feel like supporting this is the best route. I don't think there are any negative consequences of supporting this.

@devoncarew @kevmoo I don't know who's getting PR notifications for this repo, but since you both committed here recently perhaps you know who might be able to review this? Thanks :-)

@kevmoo
Copy link
Member

kevmoo commented Aug 8, 2023

I'm always nervous touching pkg:path – it's pretty stable. But this might be a good fix.

@natebosch @jakemac53 – thoughts?


/// Returns the index of the first character after the drive letter, or `null`
/// if [index] is not the start of a drive letter.
int? driveLetterEnd(String path, int index) {
Copy link
Member

Choose a reason for hiding this comment

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

[nit] What do you think about the name drivePathIndex

Can the doc call out the specific behavior when path is exactly the drive letter with no following character?

Copy link
Member

Choose a reason for hiding this comment

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

After re-reading the implementation, I think driveLetterEnd is a fine name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've update the docs, let me know if this seems ok.

Copy link
Member

@natebosch natebosch left a comment

Choose a reason for hiding this comment

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

I think the change looks good. I think the risk that someone is relying on the current behavior is low, and I'm convinced by the discussion in the linked issues that this change would be a more useful implementation.

We will need a changelog entry. I would also switch to a feature version bump 1.9.0.

@DanTup
Copy link
Contributor Author

DanTup commented Aug 9, 2023

I've pushed changes + changelog/version. I left the -wip suffix as I'm not sure when you plan to release, but I can remove it if you're likely to publish soon/with just this.

Thanks :)

@natebosch natebosch merged commit 7c2324b into dart-lang:master Aug 9, 2023
6 checks passed
mosuem pushed a commit to dart-lang/core that referenced this pull request Oct 16, 2024
Fixes dart-lang/path#148

Using `Uri().toFilePath()` handles escaped colons in drive letters, but
`Context.fromUri()` currently does not.

Allow the percent encoded colon by checking both formats and adjusting
to the correct index for the following character when the percent
encoding makes the drive letter longer than the typical two characters.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants