Skip to content
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

URL Encode path before attempting to resolve it #272

Closed
ndw opened this issue Mar 16, 2018 · 8 comments
Closed

URL Encode path before attempting to resolve it #272

ndw opened this issue Mar 16, 2018 · 8 comments

Comments

@ndw
Copy link
Owner

@ndw ndw commented Mar 16, 2018

Via email:

I tried today to integrate the new 1.1.20-98 version of the Calabash engine.
All the integration tests are failing with the following exception:

java.lang.IllegalArgumentException: Illegal character in opaque part at index 2:
D:\EclipseWorkspaces\WorkspaceSyncRo\eXml\classes
at java.net.URI.create(URI.java:852)
at java.net.URI.resolve(URI.java:1036)
at com.xmlcalabash.core.XProcConfiguration.init(XProcConfiguration.java:223)
at com.xmlcalabash.core.XProcConfiguration.<init>(XProcConfiguration.java:145)
at ro.sync.xml.transformer.xproc.calabash.XProcTransformerImpl$2.run(XProcTransformerImpl.java:208)
at ro.sync.xml.transformer.xproc.calabash.XProcTransformerImpl$2.run(XProcTransformerImpl.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at ro.sync.xml.transformer.xproc.calabash.XProcTransformerImpl.prepareRuntime(XProcTransformerImpl.java:197)
at ro.sync.xml.transformer.xproc.calabash.XProcTransformerImpl.transform(XProcTransformerImpl.java:310)
at ro.sync.xml.transformer.xproc.XProcTransformer$4.run(XProcTransformer.java:562)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.URISyntaxException: Illegal character in opaque part at index 2:
D:\EclipseWorkspaces\WorkspaceSyncRo\eXml\classes
at java.net.URI$Parser.fail(URI.java:2848)
at java.net.URI$Parser.checkChars(URI.java:3021)
at java.net.URI$Parser.parse(URI.java:3058)
at java.net.URI.<init>(URI.java:588)
at java.net.URI.create(URI.java:850)
... 10 more

Please take into account to encode the "path" before asking an URI to "resolve" it.

I patched the code as seen bellow and works fine:
--------------------------------------
String classPath = System.getProperty("java.class.path");
String[] pathElements = classPath.split(System.getProperty("path.separator"));
for (String path : pathElements) {
// Start OXYGEN PATCH
try {
path = URLEncoder.encode(path, "UTF-8");
} catch (UnsupportedEncodingException e1) {
// Neglect
}
// End OXYGEN patch

// Make the path absolute wrt the cwd so that it can be opened later regardless of context
String s = cwd.resolve(path).getPath();
ndw added a commit that referenced this issue Mar 17, 2018
ndw added a commit that referenced this issue Mar 17, 2018
ndw added a commit that referenced this issue May 31, 2018
ndw added a commit that referenced this issue May 31, 2018
@ndw ndw closed this Dec 22, 2018
@bertfrees
Copy link

@bertfrees bertfrees commented Jan 27, 2019

Something is not quite right yet in this code to resolve a jar against the cwd on Windows. We're getting this error:

java.nio.file.InvalidPathException: Illegal char <:> at index 68: C:\Users\trfre\Documents\Github\pipeline-scripts\epub3-to-daisy202\c:\Program+Files\apache-maven-3.6.0\bin\..\boot\plexus-classworlds-2.5.2.jar
        at java.base/sun.nio.fs.WindowsPathParser.normalize(Unknown Source)
        at java.base/sun.nio.fs.WindowsPathParser.parse(Unknown Source)
        at java.base/sun.nio.fs.WindowsPathParser.parse(Unknown Source)
        at java.base/sun.nio.fs.WindowsPath.parse(Unknown Source)
        at java.base/sun.nio.fs.WindowsFileSystem.getPath(Unknown Source)
        at java.base/java.io.File.toPath(Unknown Source)
        at java.base/java.util.zip.ZipFile$Source.get(Unknown Source)
        at java.base/java.util.zip.ZipFile$CleanableResource.<init>(Unknown Source)
        at java.base/java.util.zip.ZipFile$CleanableResource.get(Unknown Source)
        at java.base/java.util.zip.ZipFile.<init>(Unknown Source)
        at java.base/java.util.zip.ZipFile.<init>(Unknown Source)
        at java.base/java.util.jar.JarFile.<init>(Unknown Source)
        at java.base/java.util.jar.JarFile.<init>(Unknown Source)
        at java.base/java.util.jar.JarFile.<init>(Unknown Source)
        at com.xmlcalabash.core.XProcConfiguration.init(XProcConfiguration.java:240)
        at com.xmlcalabash.core.XProcConfiguration.<init>(XProcConfiguration.java:159)
@ndw ndw reopened this Feb 9, 2019
bertfrees added a commit to daisy/xmlcalabash1 that referenced this issue Mar 5, 2019
This reverts commit fc2e286

See ndw#272
@bertfrees
Copy link

@bertfrees bertfrees commented Mar 5, 2019

@ndw I think I have fixed this. See commit daisy@990befd.

ndw added a commit that referenced this issue Mar 6, 2019
ndw added a commit that referenced this issue Mar 6, 2019
@ndw
Copy link
Owner Author

@ndw ndw commented Mar 6, 2019

Ok. I've applied that patch. I modified it to use the utf-8 encoding explicitly, as recommended. That avoids a call to a deprecated method.

Please give the current 97 or 98 branches a whirl and let me know if you're satisfied.

@bertfrees
Copy link

@bertfrees bertfrees commented Mar 6, 2019

I don't see any differences between your and my commit?

@ndw
Copy link
Owner Author

@ndw ndw commented Mar 6, 2019

I added the encoding to the .decode() method call.

@bertfrees
Copy link

@bertfrees bertfrees commented Mar 6, 2019

OK I see now, it's in the next commit :)

ndw added a commit that referenced this issue Mar 6, 2019
ndw added a commit that referenced this issue Mar 6, 2019
@bertfrees
Copy link

@bertfrees bertfrees commented Mar 7, 2019

OK looks good!

ndw added a commit that referenced this issue Mar 21, 2019
ndw added a commit that referenced this issue Mar 21, 2019
@ndw
Copy link
Owner Author

@ndw ndw commented Mar 22, 2019

Fixed in 1.1.25, I believe.

@ndw ndw closed this Mar 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants