Skip to content

Commit 3955646

Browse files
committed
1466-instantiate-csv-data-as-rdf: Fix code scanning alert #8.
1 parent f0adf60 commit 3955646

File tree

1 file changed

+4
-3
lines changed
  • stack-clients/src/main/java/com/cmclinnovations/stack/clients/utils

1 file changed

+4
-3
lines changed

stack-clients/src/main/java/com/cmclinnovations/stack/clients/utils/FileUtils.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,13 @@ private static Set<URI> listFilesFromJar(URL dirURL) throws IOException {
119119
}
120120
}
121121
String cleanedDirURL = dirURL.toString().replaceFirst("^(.*?)/?$", "$1/");
122+
Path basePath = Path.of(path).normalize();
122123
try (JarFile jar = new JarFile(jarPath)) {
123124
Enumeration<JarEntry> entries = jar.entries(); // gives ALL entries in jar
124125
while (entries.hasMoreElements()) {
125-
String name = entries.nextElement().getName();
126-
if (name.startsWith(path)) { // filter according to the path
127-
String entry = name.substring(path.length());
126+
Path name = Path.of(entries.nextElement().getName()).normalize();
127+
if (name.startsWith(basePath)) { // filter according to the path
128+
String entry = basePath.relativize(name).toString();
128129
if (!entry.isEmpty() && !entry.contains("/")) {
129130
uris.add(URI.create(cleanedDirURL + entry));
130131
}

0 commit comments

Comments
 (0)