|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
73 | 73 | * @test
|
74 | 74 | * @bug 6990846 7009092 7009085 7015391 7014948 7005986 7017840 7007596
|
75 | 75 | * 7157656 8002390 7012868 7012856 8015728 8038500 8040059 8069211
|
76 |
| - * 8131067 8034802 8210899 |
| 76 | + * 8131067 8034802 8210899 8273961 |
77 | 77 | * @summary Test Zip filesystem provider
|
78 | 78 | * @modules jdk.zipfs
|
79 | 79 | * @run main ZipFSTester
|
@@ -689,10 +689,19 @@ private static FileSystem newZipFileSystem(Path path, Map<String, ?> env)
|
689 | 689 | throws Exception
|
690 | 690 | {
|
691 | 691 | // Use URLDecoder (for test only) to remove the double escaped space
|
692 |
| - // character |
| 692 | + // character. For the path which is not encoded by UTF-8, we need to |
| 693 | + // replace "+" by "%2b" manually before feeding into the decoder. |
| 694 | + // Otherwise, the URLDecoder would replace "+" by " ", which may |
| 695 | + // raise NoSuchFileException. |
| 696 | + // |
| 697 | + // eg. var path = "file:///jdk-18+9/basic.jar"; |
| 698 | + // URLDecoder.decode(path, "utf8") -> file:///jdk-18 9/basic.jar |
| 699 | + // |
| 700 | + // Also, we should not use URLEncoder in case of the path has been |
| 701 | + // encoded. |
693 | 702 | return FileSystems.newFileSystem(
|
694 |
| - new URI("jar", URLDecoder.decode(path.toUri().toString(), "utf8"), |
695 |
| - null), env, null); |
| 703 | + new URI("jar", URLDecoder.decode(path.toUri().toString() |
| 704 | + .replace("+", "%2b"), "utf8"), null), env, null); |
696 | 705 | }
|
697 | 706 |
|
698 | 707 | private static Path getTempPath() throws IOException
|
|
0 commit comments