elharo opened a new pull request, #384:
URL: https://github.com/apache/maven-shared-utils/pull/384
The regex `^\\[a-zA-Z]:` at lines 146 and 149 had two bugs:
1. The `\\[` matched a literal `[` character, not a backslash, because `[`
was escaped by `\`
2. `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 path
The Windows drive-letter normalization code was effectively dead. Paths like
`\C:\foo` (produced by `File.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 of `null`).
**Fix:** Replaced the broken regex with a simple character-level check:
```java
if (toPath.length() > 2 && toPath.charAt(0) == '\\'
&& Character.isLetter(toPath.charAt(1)) && toPath.charAt(2) == ':')
```
Fixes 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]