mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* file.c (rb_file_expand_path_internal): fix r42160; skip '~'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
044e75db6d
commit
f86be91b56
3 changed files with 10 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Fri Jul 26 01:21:41 2013 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* file.c (rb_file_expand_path_internal): fix r42160; skip '~'.
|
||||||
|
|
||||||
Thu Jul 25 17:53:18 2013 NARUSE, Yui <naruse@ruby-lang.org>
|
Thu Jul 25 17:53:18 2013 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* lib/net/http.rb (Net::HTTP#connect): disable Nagle's algorithm on
|
* lib/net/http.rb (Net::HTTP#connect): disable Nagle's algorithm on
|
||||||
|
|
1
file.c
1
file.c
|
@ -2990,6 +2990,7 @@ rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_na
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
s = nextdirsep(b = s, fend, enc);
|
s = nextdirsep(b = s, fend, enc);
|
||||||
|
b++; /* b[0] is '~' */
|
||||||
userlen = s - b;
|
userlen = s - b;
|
||||||
BUFCHECK(bdiff + userlen >= buflen);
|
BUFCHECK(bdiff + userlen >= buflen);
|
||||||
memcpy(p, b, userlen);
|
memcpy(p, b, userlen);
|
||||||
|
|
|
@ -669,6 +669,11 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
assert_raise(ArgumentError, bug) { File.expand_path("~anything") }
|
assert_raise(ArgumentError, bug) { File.expand_path("~anything") }
|
||||||
end if DRIVE
|
end if DRIVE
|
||||||
|
|
||||||
|
def test_expand_path_for_existent_username
|
||||||
|
user = ENV['USER']
|
||||||
|
assert_equal(ENV['HOME'], File.expand_path("~#{user}"))
|
||||||
|
end unless DRIVE
|
||||||
|
|
||||||
def test_expand_path_error_for_nonexistent_username
|
def test_expand_path_error_for_nonexistent_username
|
||||||
user = "\u{3086 3046 3066 3044}:\u{307F 3084 304A 3046}"
|
user = "\u{3086 3046 3066 3044}:\u{307F 3084 304A 3046}"
|
||||||
assert_raise_with_message(ArgumentError, /#{user}/) {File.expand_path("~#{user}")}
|
assert_raise_with_message(ArgumentError, /#{user}/) {File.expand_path("~#{user}")}
|
||||||
|
|
Loading…
Reference in a new issue