RFR: 8287237: (fs) Files.probeContentType returns null if filename contains hash mark on Linux [v2]
Jaikiran Pai
jpai at openjdk.java.net
Sat May 28 14:42:29 UTC 2022
On Fri, 27 May 2022 19:09:05 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> Modify `sun.net.www.MimeTable.findByFileName(String)` to attempt to find the file extension in the entire file name if it is not found in the portion of the name preceding the optional fragment beginning with a hash (`#`).
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>
> 8287237: Refactor and clean up
src/java.base/share/classes/sun/net/www/MimeTable.java line 188:
> 186: int hashIndex = fname.lastIndexOf(HASH_MARK);
> 187: if (hashIndex > 0) {
> 188: String ext = getFileExtension(fname.substring(0, hashIndex - 1));
Hello Brian, I think there's a bug here. Not introduced by this PR but even in the current master. I think that `fname.substring(0, hashIndex -1)` call should actually be `fname.substring(0, hashIndex)`. For example, in its current form, if `fname` is `a.png#foo` then `fname.substring(...)` here will return `a.pn` instead of `a.png`. It looks like we don't have a test for that case.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8909
More information about the nio-dev
mailing list