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

Pathname#relative_path_from failing when there are certain unicode characters in the path #3396

Closed
hading opened this issue Oct 14, 2015 · 1 comment
Assignees
Milestone

Comments

@hading
Copy link

hading commented Oct 14, 2015

jruby-9.0.0.0 :007 > x = "joe"
=> "joe"
jruby-9.0.0.0 :008 > y = "joe/⸀䐀攀氀攀琀攀䴀攀/fred"
=> "joe/⸀䐀攀氀攀琀攀䴀攀/fred"
jruby-9.0.0.0 :009 > Pathname.new(y).relative_path_from(Pathname.new(x))
TypeError: no implicit conversion from nil to integer
from org/jruby/RubyString.java:2870:in []' from /services/medusa/.rvm/rubies/jruby-9.0.0.0/lib/ruby/stdlib/pathname.rb:48:inchop_basename'
from /services/medusa/.rvm/rubies/jruby-9.0.0.0/lib/ruby/stdlib/pathname.rb:113:in cleanpath_aggressive' from /services/medusa/.rvm/rubies/jruby-9.0.0.0/lib/ruby/stdlib/pathname.rb:91:incleanpath'
from /services/medusa/.rvm/rubies/jruby-9.0.0.0/lib/ruby/stdlib/pathname.rb:493:in relative_path_from' from (irb):9:in'
from org/jruby/RubyKernel.java:979:in eval' from org/jruby/RubyKernel.java:1292:inloop'
from org/jruby/RubyKernel.java:1099:in catch' from org/jruby/RubyKernel.java:1099:incatch'
from /services/medusa/.rvm/rubies/jruby-9.0.0.0/bin/irb:13:in `'

Here's the MRI version, which works:

2.2.3 :006 > x = "joe"
=> "joe"
2.2.3 :007 > y = "joe/⸀䐀攀氀攀琀攀䴀攀/fred"
=> "joe/⸀䐀攀氀攀琀攀䴀攀/fred"
2.2.3 :008 > Pathname.new(y).relative_path_from(Pathname.new(x))
=> #Pathname:⸀䐀攀氀攀琀攀䴀攀/fred

I discovered this at the same time as issue #3392. They appear to be different problems, though.

@kares kares self-assigned this Jun 23, 2017
kares added a commit that referenced this issue Jun 23, 2017
upper bound check should not halt the loop since we're going pos--
(and there's a chance were able to find a match at a lower position)
@kares kares added this to the JRuby 9.2.0.0 milestone Jun 23, 2017
@kares
Copy link
Member

kares commented Jun 23, 2017

this bug slipped quite into oblivion - its an ugly piece show-casing String#rindex isn't working properly for certain UTF-8 strings. c24f7fa resolved the issue.

@kares kares closed this as completed Jun 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants