Changeset 7214
- Timestamp:
- 07/24/07 01:40:13 (1 year ago)
- Files:
-
- plugins/open_id_authentication/CHANGELOG (modified) (1 diff)
- plugins/open_id_authentication/lib/open_id_authentication.rb (modified) (1 diff)
- plugins/open_id_authentication/test/normalize_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/open_id_authentication/CHANGELOG
r7162 r7214 1 * Use URI instead of regexps to normalize the URL and gain free, better matching #8136 [dkubb] 2 1 3 * Allow -'s in #normalize_url [Rick] 2 4 plugins/open_id_authentication/lib/open_id_authentication.rb
r7163 r7214 58 58 59 59 def self.normalize_url(url) 60 url = url.downcase 61 62 case url 63 when %r{^https?://[^/]+/[^/]*} 64 url # already normalized 65 when %r{^https?://[^/]+$} 66 url + "/" 67 when %r{^[.\d\w-]+/.*$} 68 "http://" + url 69 when %r{^[.\d\w-]+$} 70 "http://" + url + "/" 71 else 60 begin 61 uri = URI.parse(url) 62 uri = URI.parse("http://#{uri}") unless uri.scheme 63 uri.scheme = uri.scheme.downcase # URI should do this 64 uri.normalize.to_s 65 rescue URI::InvalidURIError 72 66 raise InvalidOpenId.new("#{url} is not an OpenID URL") 73 67 end plugins/open_id_authentication/test/normalize_test.rb
r7162 r7214 10 10 11 11 NORMALIZATIONS = { 12 "openid.aol.com/nextangler" => "http://openid.aol.com/nextangler", 13 "http://openid.aol.com/nextangler" => "http://openid.aol.com/nextangler", 14 "https://openid.aol.com/nextangler" => "https://openid.aol.com/nextangler", 15 "loudthinking.com" => "http://loudthinking.com/", 16 "http://loudthinking.com" => "http://loudthinking.com/", 17 "techno-weenie.net" => "http://techno-weenie.net/", 18 "http://techno-weenie.net" => "http://techno-weenie.net/" 12 "openid.aol.com/nextangler" => "http://openid.aol.com/nextangler", 13 "http://openid.aol.com/nextangler" => "http://openid.aol.com/nextangler", 14 "https://openid.aol.com/nextangler" => "https://openid.aol.com/nextangler", 15 "HTTP://OPENID.AOL.COM/NEXTANGLER" => "http://openid.aol.com/NEXTANGLER", 16 "HTTPS://OPENID.AOL.COM/NEXTANGLER" => "https://openid.aol.com/NEXTANGLER", 17 "loudthinking.com" => "http://loudthinking.com/", 18 "http://loudthinking.com" => "http://loudthinking.com/", 19 "http://loudthinking.com:80" => "http://loudthinking.com/", 20 "https://loudthinking.com:443" => "https://loudthinking.com/", 21 "http://loudthinking.com:8080" => "http://loudthinking.com:8080/", 22 "techno-weenie.net" => "http://techno-weenie.net/", 23 "http://techno-weenie.net" => "http://techno-weenie.net/" 19 24 } 20 25