You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "elharo (via GitHub)" <gi...@apache.org> on 2026/07/01 12:31:39 UTC
[I] PathTool.getRelativeFilePath broken Windows drive letter regex [maven-shared-utils]
elharo opened a new issue, #383:
URL: https://github.com/apache/maven-shared-utils/issues/383
`PathTool.getRelativeFilePath()` has a broken regex for matching Windows drive letters at lines 146 and 149:
```java
if (toPath.matches("^\\[a-zA-Z]:")) {
toPath = toPath.substring(1);
}
```
The regex `^\\[a-zA-Z]:` contains an erroneous `\` before `[`, so instead of matching a backslash + drive letter (e.g. `\C:`), it matches the literal string `[a-zA-Z]:`. The intent was to match a leading backslash followed by a drive letter — paths like `\C:\foo` that `File.getPath()` can produce on Windows when given `/C:/foo`.
The correct regex should be `^\\\\[a-zA-Z]:` which in a Java string becomes `"^\\\\[a-zA-Z]:"` — matching a literal backslash, a letter, and a colon at the start of the string.
This means the drive-letter normalization code is effectively dead on Windows, causing incorrect relative paths or `null` returns when paths have a leading separator before the drive letter.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] PathTool.getRelativeFilePath broken Windows drive letter regex [maven-shared-utils]
Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo closed issue #383: PathTool.getRelativeFilePath broken Windows drive letter regex
URL: https://github.com/apache/maven-shared-utils/issues/383
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org