Permalink
Browse files

Ensure argument is not modified by File.expand_path. Closes #351.

The use of #size versus #length is to disambiguate the use
of length.
  • Loading branch information...
1 parent 5f9fdcb commit 155f91deb957a4fed0a0dcd2c8e8cc0d9794e41e Brian Ford committed Jun 9, 2010
Showing with 3 additions and 3 deletions.
  1. +3 −3 kernel/common/file.rb
View
@@ -363,20 +363,20 @@ def self.expand_path(path, dir=nil)
if first == ?~
case path[1]
when ?/
- path[0, 1] = ENV["HOME"]
+ path = ENV["HOME"] + path.substring(1, path.size - 1)
when nil
return ENV["HOME"]
else
unless length = path.index("/", 1)
- length = path.length
+ length = path.size
end
name = path.substring 1, length - 1
unless dir = Rubinius.get_user_home(name)
raise ArgumentError, "user #{name} does not exist"
end
- path[0, length] = dir
+ path = dir + path.substring(length, path.size - length)
end
elsif first != ?/
if dir

0 comments on commit 155f91d

Please sign in to comment.