-
Bug
-
Resolution: Unresolved
-
P4
-
17, 20, 21
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
Given a java.nio.file.FileSystem instance created from a zip file, when FileSystem.getPath() is called with the first argument being a string containing a '\' character, the returned Path instance does not refer to the correct filename; '\' is mistakenly treated as a path separator while it actually is a valid character name in a zip file.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Create a file named 'odd-resource.zip' containing a file called 'nested-reserved-!#\\$%&()*+,:=?@[]-meta-inf-resource.txt' under a 'META-INF/resources' folder.
2) Compile and run the ZipFsTest class.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
This should be printed:
listed Path = nested-reserved-!#\\$%&()*+,:=?@[]-meta-inf-resource.txt
gotten Path = nested-reserved-!#\\$%&()*+,:=?@[]-meta-inf-resource.txt
Equal? true
ACTUAL -
This gets printed:
listed Path = nested-reserved-!#\\$%&()*+,:=?@[]-meta-inf-resource.txt
gotten Path = $%&()*+,:=?@[]-meta-inf-resource.txt
Equal? false
---------- BEGIN SOURCE ----------
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
public class ZipFsTest
{
public static void main(String[] args) throws Exception
{
try (FileSystem fs = FileSystems.newFileSystem(Path.of("odd-resource.jar"), new HashMap<String, String>()))
{
Path pathListed = Files.list(fs.getPath("/META-INF/resources")).findFirst().orElseThrow();
Path pathGotten = fs.getPath("/META-INF/resources/nested-reserved-!#\\\\$%&()*+,:=?@[]-meta-inf-resource.txt");
System.out.println("listed Path = " + pathListed.getFileName());
System.out.println("gotten Path = " + pathGotten.getFileName());
System.out.println("Equal? " + pathListed.getFileName().toString().equals(pathGotten.getFileName().toString()));
}
}
}
---------- END SOURCE ----------
FREQUENCY : always
Given a java.nio.file.FileSystem instance created from a zip file, when FileSystem.getPath() is called with the first argument being a string containing a '\' character, the returned Path instance does not refer to the correct filename; '\' is mistakenly treated as a path separator while it actually is a valid character name in a zip file.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Create a file named 'odd-resource.zip' containing a file called 'nested-reserved-!#\\$%&()*+,:=?@[]-meta-inf-resource.txt' under a 'META-INF/resources' folder.
2) Compile and run the ZipFsTest class.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
This should be printed:
listed Path = nested-reserved-!#\\$%&()*+,:=?@[]-meta-inf-resource.txt
gotten Path = nested-reserved-!#\\$%&()*+,:=?@[]-meta-inf-resource.txt
Equal? true
ACTUAL -
This gets printed:
listed Path = nested-reserved-!#\\$%&()*+,:=?@[]-meta-inf-resource.txt
gotten Path = $%&()*+,:=?@[]-meta-inf-resource.txt
Equal? false
---------- BEGIN SOURCE ----------
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
public class ZipFsTest
{
public static void main(String[] args) throws Exception
{
try (FileSystem fs = FileSystems.newFileSystem(Path.of("odd-resource.jar"), new HashMap<String, String>()))
{
Path pathListed = Files.list(fs.getPath("/META-INF/resources")).findFirst().orElseThrow();
Path pathGotten = fs.getPath("/META-INF/resources/nested-reserved-!#\\\\$%&()*+,:=?@[]-meta-inf-resource.txt");
System.out.println("listed Path = " + pathListed.getFileName());
System.out.println("gotten Path = " + pathGotten.getFileName());
System.out.println("Equal? " + pathListed.getFileName().toString().equals(pathGotten.getFileName().toString()));
}
}
}
---------- END SOURCE ----------
FREQUENCY : always