PathTool.getRelativeFilePath: fix broken Windows drive-letter regex#384
Open
elharo wants to merge 3 commits into
Open
PathTool.getRelativeFilePath: fix broken Windows drive-letter regex#384elharo wants to merge 3 commits into
elharo wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The regex
^\\[a-zA-Z]:at lines 146 and 149 had two bugs:\\[matched a literal[character, not a backslash, because[was escaped by\String.matches()requires the entire string to match the pattern, but this regex was intended to match only the leading\C:prefix — so it never matched any real pathThe Windows drive-letter normalization code was effectively dead. Paths like
\C:\foo(produced byFile.getPath()on Windows) were never getting their leading\stripped, causing the drive-letter comparison logic at lines 154–175 to be skipped. This could produce incorrect relative paths or fail to detect mismatched drives (returning a path instead ofnull).Fix: Replaced the broken regex with a simple character-level check:
Fixes #383