Skip to content

Commit

Permalink
normalize_url treats nil url as blank
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.rubyonrails.org/rails/plugins/open_id_authentication@8931 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
bitsweat committed Feb 27, 2008
1 parent b00b0c6 commit 27db6c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/open_id_authentication.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'uri'

module OpenIdAuthentication
OPEN_ID_AUTHENTICATION_DIR = RAILS_ROOT + "/tmp/openids"

Expand Down Expand Up @@ -57,7 +59,7 @@ def message
end

def self.normalize_url(url)
uri = URI.parse(url.strip)
uri = URI.parse(url.to_s.strip)
uri = URI.parse("http://#{uri}") unless uri.scheme
uri.scheme = uri.scheme.downcase # URI should do this
uri.normalize.to_s
Expand Down
3 changes: 2 additions & 1 deletion test/normalize_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ def test_normalizations
assert_equal to, normalize_url(from)
end
end

def test_broken_open_id
assert_raises(InvalidOpenId) { normalize_url(nil) }
assert_raises(InvalidOpenId) { normalize_url("=name") }
end
end

0 comments on commit 27db6c7

Please sign in to comment.