RFR: 8354450: Using a File with a path containing a trailing space should fail when alternative data streams are disabled (win) [v3]
Brian Burkhalter
bpb at openjdk.org
Tue Apr 22 17:48:49 UTC 2025
On Tue, 22 Apr 2025 15:56:10 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8354450: Account for spaces in directory elements; update test
>
> src/java.base/windows/classes/java/io/WinNTFileSystem.java line 376:
>
>> 374: return true;
>> 375: theFile = theFile.getParentFile();
>> 376: } while (theFile != null);
>
> The input has already been normalized so I think you can reduce it down to searching getPath for a trailing space or a backslash followed by a space.
Using `Path.of` with various inputs yields the following:
"root\dir\subdir\file.txt" is valid
"root \dir\subdir\file.txt" is invalid
"root\ dir\subdir\file.txt" is valid
"root\dir \subdir\file.txt" is invalid
"root\dir\ subdir\file.txt" is valid
"root\dir\subdir \file.txt" is invalid
"root\dir\subdir\ file.txt" is valid
"root\dir\subdir\file.txt " is invalid
Apparently that method at least thinks that a backslash followed by a space is acceptable ("invalid" == `InvalidPathException` caught).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24635#discussion_r2054577045
More information about the core-libs-dev
mailing list