-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Pathname#relative_path_from failing when there is a '!' character in the path #3392
Comments
this is true and it is onaly a problem with an ! at the end of the name. there are quite some places where we discover jar urls like my.jar!/script.rb by looking for !/ |
To give more detail, I found the problem in the context of digital preservation in a library. We get sets of files with all kinds of bizarre (to me) naming convention/directory structures coming from our various units. In particular our archive unit is likely to get weird stuff and want to preserve it as is. I think the particular case I found was something like ../../PLUS!/../... So if a general solution is possible I'd certainly be appreciative, but I do bear in mind that I wouldn't be the one doing it. Also I'm a little confused by the idea that it is a legacy feature - is there equivalent functionality for Pathname#relative_path_from elsewhere in ruby or the stdlib? Thanks, |
the legacy feature is to allow such jar like paths with file: or jar:file: or no protocol prefix at all. I will have a look and please feel free to report any other pathname/directory-name which gives you problems. |
Thanks. I was getting another (different) error that went away when I hacked around this issue, but I'll see if I can reproduce it and see if it is a jruby issue or not. |
I found the other problem. Let me know if you'd like me to open another ticket for it. This time it's when the path involves some unicode characters: jruby-9.0.0.0 :007 > x = "joe" Here's the MRI version, which works: 2.2.3 :006 > x = "joe" |
please file a second issue since it is really something else going wrong ;) |
Okay, filed as issue #3396. |
For jruby-9.0.1.0 (discovered on 9.0.0.0). I don't know if there are other characters that trigger this.
E.g.
jruby-9.0.1.0 :001 > require 'pathname'
=> true
jruby-9.0.1.0 :002 > x = "joe"
=> "joe"
jruby-9.0.1.0 :003 > y = "joe/pete!/bob"
=> "joe/pete!/bob"
jruby-9.0.1.0 :004 > Pathname.new(y).relative_path_from(Pathname.new(x))
ArgumentError: different prefix: "joe/pete!/" and "joe"
from /Users/hding2/.rvm/rubies/jruby-9.0.1.0/lib/ruby/stdlib/pathname.rb:508:in
relative_path_from' from (irb):4:in
'from org/jruby/RubyKernel.java:978:in
eval' from org/jruby/RubyKernel.java:1291:in
loop'from org/jruby/RubyKernel.java:1098:in
catch' from org/jruby/RubyKernel.java:1098:in
catch'from /Users/hding2/.rvm/rubies/jruby-9.0.1.0/bin/irb:13:in `'
In ruby-2.2.3:
2.2.3 :001 > require 'pathname'
=> true
2.2.3 :002 > x = "joe"
=> "joe"
2.2.3 :003 > y = "joe/pete!/bob"
=> "joe/pete!/bob"
2.2.3 :004 > Pathname.new(y).relative_path_from(Pathname.new(x))
=> #Pathname:pete!/bob
The text was updated successfully, but these errors were encountered: