Skip to content
Permalink
Browse files
8273961: jdk/nio/zipfs/ZipFSTester.java fails if file path contains '…
…+' character

Reviewed-by: mdoerr
Backport-of: 7f78803b0926ea194334ad9b3c9f06cbe17a83dd
  • Loading branch information
GoeLin committed Oct 11, 2021
1 parent 4e63adb commit bcee700e708f689b8ca83e9d65e9971542d363c9
Showing 1 changed file with 14 additions and 5 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -73,7 +73,7 @@
* @test
* @bug 6990846 7009092 7009085 7015391 7014948 7005986 7017840 7007596
* 7157656 8002390 7012868 7012856 8015728 8038500 8040059 8069211
* 8131067 8034802 8210899
* 8131067 8034802 8210899 8273961
* @summary Test Zip filesystem provider
* @modules jdk.zipfs
* @run main ZipFSTester
@@ -689,10 +689,19 @@ private static FileSystem newZipFileSystem(Path path, Map<String, ?> env)
throws Exception
{
// Use URLDecoder (for test only) to remove the double escaped space
// character
// character. For the path which is not encoded by UTF-8, we need to
// replace "+" by "%2b" manually before feeding into the decoder.
// Otherwise, the URLDecoder would replace "+" by " ", which may
// raise NoSuchFileException.
//
// eg. var path = "file:///jdk-18+9/basic.jar";
// URLDecoder.decode(path, "utf8") -> file:///jdk-18 9/basic.jar
//
// Also, we should not use URLEncoder in case of the path has been
// encoded.
return FileSystems.newFileSystem(
new URI("jar", URLDecoder.decode(path.toUri().toString(), "utf8"),
null), env, null);
new URI("jar", URLDecoder.decode(path.toUri().toString()
.replace("+", "%2b"), "utf8"), null), env, null);
}

private static Path getTempPath() throws IOException

1 comment on commit bcee700

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on bcee700 Oct 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.