RFR: 8287843: File::getCanonicalFile doesn't work for \?\C:\ style paths DOS device paths [v2]
Alan Bateman
alanb at openjdk.org
Sat Sep 9 08:35:47 UTC 2023
On Fri, 8 Sep 2023 01:07:17 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> In the Windows implementation of java.io.File.getCanonicalPath, strip any long path or UNC prefix before canonicalizing the remainder of the pathname.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>
> 8287843: Handle "\\?\UNC"; add bad paths to test
For `\\\?\`, the normalization will drop the trailing slash so the path string is actually `\\\?`. I that that case is okay.
For input such as `\\\?\\foo` and `\\\?\\C:`, the stripping results in a relative path, `foo` and `C:` in these examples, which means the canonicalize code is starting with a relative path. We have to be careful here as the path has always been make absolute before attempting to canonicalize.
For `\\\?\\UNC` and `\\\?\\UNC\`, the stripping means these will be treated as `\`, which is the root directory of the current volume. I know these will fail with "The network path was not path" but I can't help thinking it would reject/throw early.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/15603#issuecomment-1712457295
More information about the core-libs-dev
mailing list