--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/clojure-dev/-/aOTRj5W8lbYJ.
To post to this group, send email to cloju...@googlegroups.com.
To unsubscribe from this group, send email to clojure-dev...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/clojure-dev?hl=en.
The fix to File -> URL coercion is fine, but the fix to URL -> File
coercion isn't.
URLDecoder is actually a query-string decoder, not a URL path decoder,
so the patch converts +'s in URLs to spaces, which is incorrect. (I
generally avoid using the term url-encoded to avoid this confusion).
--
Dave
Even the suggested Plexus Utilities gets it wrong too, by treating the
percent encoding as iso-8859-1 characters rather than utf-8 octets.
Commons IO gets that right.
--
Dave
0. <strikethrough>depend on Commons IO</strikethrough>
1. Re-implement the Commons IO toFile conversion, which is ~15 lines
and would get smaller in Clojure
(http://grepcode.com/file/repo1.maven.org/maven2/commons-io/commons-io/1.2/org/apache/commons/io/FileUtils.java#FileUtils.toFile%28java.net.URL%29)
2. Use (File. (URI. (.toExternalForm url))), like the last example
given at http://maven.apache.org/plugin-developers/common-bugs.html#Converting_between_URLs_and_Filesystem_Paths,
and just don't allow converting malformed URLs from pre-1.4 or Maven
2.x classloaders.
#1 is straightforward and seems the most helpful, and it seems like a
nice-to-have for clojure.java.io anyway. I'm assuming we don't need to
worry about licensing here.
#2 seems less good, though I don't have a strong opinion about whether
the ability to handle malformed URLs here is a requirement.
What do you think? Are there other options? If there's a consensus
around one of these (or another), I'm happy to do an updated patch.
- Colin
> --
> You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
> To post to this group, send email to cloju...@googlegroups.com.
> To unsubscribe from this group, send email to clojure-dev...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/clojure-dev?hl=en.
>
>
--
Colin Jones
Clojure requires Java 1.5 anyway, so it would only be an issue if
people call getResource on a Maven classloader for affected issues of
Maven. That doesn't sound too bad.
--
Dave
- (File. "baz") (URL. "file:baz")
- (File. "quux") (URI. "file:quux")
+ (File. "baz") (URL. "file:/baz")
+ (File. "quux") (URI. "file:/quux")
But after seeing the scary error, and not knowing all the intricacies
of RFC 2396, I worry that there might be places where these malformed
URLs might happen in the wild. Is this something we should worry
about? That Maven article names 2 groups of classloaders, and as you
mention, one is kind of moot, but could there be more? Or other ways,
like (URI. "file:foo.txt"), for malformed URI objects to get generated
that we should nevertheless support? FWIW, googling the exception
message, "uri is not hierarchical", gets quite a few hits, which feels
like evidence that it happens, but may all be due to those specific
classloaders...
I'm not convinced one way or another that the bad URLs should be
supported, but this would be a breaking change for them, as they
currently kind of work. So at this point I'm leaning towards the
CommonsIO string-translation approach.
Thoughts?
See the difference here:
With clojure.string: https://gist.github.com/e240ea21d93638df6c26
Without: https://gist.github.com/42584777aceaab6625e4
Granted, the second example tends a bit towards straw man territory;
there are surely some simplifications available there. But the core
algorithm isn't going to get much clearer without doing something
drastic to abstract away the loop-recur holdover from the more direct
translation from Java. So I haven't yet taken the time to really clean
that up seriously, since I so much prefer the clojure.string/replace
solution. Performance-wise, it's probably a bit of a hit to do regexp
matching, but I'm not sure whether it's more than instantiating a
bunch of new strings, as CommonsIO does.
Thoughts? I'll post an updated patch to JIRA tomorrow for the
clojure.string version if nobody sees problems with the basic idea
right away.
--
Colin Jones
I'm not sure what I need to do process-wise to get vetting/screening,
but I'm assuming I haven't done it yet. I also don't have permissions
to edit any fields on the ticket (not sure whether that's required).
If someone knows what the next step should be, could they point me in
the right direction?
Thanks!
- Colin
--
Colin Jones