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 · 0 comments

Comments

Projects
None yet
1 participant
@ndw
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment