Skip to content

Commit c2cbd55

Browse files
committed
Don't include bad password in URI exception output
We shouldn't include the bad password in the URI exception output message. Just knowing that there is a bad password is enough information. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 7070c5b commit c2cbd55

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

ChangeLog

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Fri Sep 16 06:43:25 2016 Aaron Patterson <tenderlove@ruby-lang.org>
2+
3+
* lib/uri/generic.rb (def check_password): don't include bad password
4+
in URI exception output
5+
6+
* test/uri/test_generic.rb (def test_set_component): test for behavior
7+
18
Thu Sep 15 21:40:03 2016 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
29

310
* doc/extension.ja.rdoc: Fix file name.

lib/uri/generic.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ def check_password(v, user = @user)
428428

429429
if parser.regexp[:USERINFO] !~ v
430430
raise InvalidComponentError,
431-
"bad component(expected user component): #{v}"
431+
"bad password component"
432432
end
433433

434434
return true

test/uri/test_generic.rb

+9
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,15 @@ def test_set_component
749749
assert_equal('foo:xyzzy', uri.to_s)
750750
end
751751

752+
def test_bad_password_component
753+
uri = URI.parse('http://foo:bar@baz')
754+
password = 'foo@bar'
755+
e = assert_raise(URI::InvalidComponentError) do
756+
uri.password = password
757+
end
758+
refute_match password, e.message
759+
end
760+
752761
def test_set_scheme
753762
uri = URI.parse 'HTTP://example'
754763

0 commit comments

Comments
 (0)