New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to resolve UNC-based MANIFEST classpath entries #736
Comments
@jdeppe-pivotal Thanks for the report. I'm really low on time I can spend on ClassGraph right now, especially for Windows development (for the previous UNC bug it took several hours to get a Windows VM installed and working) -- any chance you could please step through to see where the additional slash is being dropped? This would be the place to start:
|
This diff gets things working for me. I'm not sure if this is the right thing to do here though. It's annoying that UNC paths are so ambiguous and don't have an explicit scheme associated with them. diff --git a/src/main/java/nonapi/io/github/classgraph/utils/FileUtils.java b/src/main/java/nonapi/io/github/classgraph/utils/FileUtils.java
index 9f4bfeca..d776eb6f 100644
--- a/src/main/java/nonapi/io/github/classgraph/utils/FileUtils.java
+++ b/src/main/java/nonapi/io/github/classgraph/utils/FileUtils.java
@@ -178,7 +178,8 @@ public final class FileUtils {
}
// Handle "..", "." and empty path segments, if any were found
- final boolean pathHasInitialSlash = pathLen > 0 && pathChars[0] == '/';
+ final boolean pathHasInitialSlash = pathChars[0] == '/';
+ final boolean pathHasInitialSlashSlash = pathHasInitialSlash && pathLen > 1 && pathChars[1] == '/';
final StringBuilder pathSanitized = new StringBuilder(pathLen + 16);
if (foundSegmentToSanitize) {
// Sanitize between "!" section markers separately (".." should not apply past preceding "!")
@@ -231,6 +232,11 @@ public final class FileUtils {
pathSanitized.append(path);
}
+ // Intended to preserve the double slash at the start of UNC paths. Example: //server/file/path
+ if (pathHasInitialSlashSlash) {
+ pathSanitized.insert(0, '/');
+ }
+
int startIdx = 0;
if (removeInitialSlash || !pathHasInitialSlash) {
// Strip off leading "/" if it needs to be removed, or if it wasn't present in the original path |
Thanks for figuring out the fix, looks good to me. Released in 4.8.152. |
Very similar to #705 but where a MANIFEST classpath entry is detected in a jar in a UNC-based file.
So If I have a jar file with a MANIFEST classpath entry on a UNC file the classpath entries are not resolved to the UNC location. Here is a snippet from a debug log:
As you can see, the classpath entries are not resolved correctly.
The text was updated successfully, but these errors were encountered: