Backport #2428
URI::Generic#eql? broken when passed nil
| Status: | Closed | Start date: | 12/04/2009 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 100% |
||
| Category: | - | |||
| Target version: | - |
Description
URI::Generic#eql? does not check for nil:
def eql?(oth)
self.component_ary.eql?(oth.component_ary)
end
Test Case:
require 'uri'
uri = URI.parse 'http://gemcutter.org'
uri.eql?(nil) # => blows up
Fix:
def eql?(oth)
return true if self.equal?(oth)
self.class.equal?(oth.class) &&
self.component_ary.eql?(oth.component_ary)
end
Associated revisions
lib/uri/generic.rb: Backport #2428 [ruby-core:27019]; fixed #eql? so that it can handle being passed a nil value.
test/generic/test_generic.rb: added a test for the fix to #eql?.
History
Updated by ujihisa (ujihisa .) over 2 years ago
- Status changed from Open to Assigned
- Assignee set to akr (Akira Tanaka)
Updated by ujihisa (ujihisa .) over 2 years ago
Ditto on 1.9.2dev. (The error message is different) ruby 1.9.2dev (2009-12-04 trunk 25986) [i386-darwin9.8.0] /Users/ujihisa/rubies/lib/ruby/1.9.1/uri/generic.rb:1069:in `eql?': undefined method `parser' for nil:NilClass (NoMethodError) from /var/folders/Dz/Dz5WpFSZGUaFLA8jp8kT5E+++TM/-Tmp-/v766166/63:5:in `<main>'
Updated by marcandre (Marc-Andre Lafortune) over 2 years ago
- Category set to lib
- Status changed from Assigned to Closed
This issue was solved with changeset r26168 and 26169. Peter, thank you for reporting this issue. Your contribution to Ruby is greatly appreciated. May Ruby be with you.
Updated by shyouhei (Shyouhei Urabe) about 2 years ago
- Status changed from Closed to Assigned
- Assignee changed from akr (Akira Tanaka) to shyouhei (Shyouhei Urabe)
Updated by shyouhei (Shyouhei Urabe) almost 2 years ago
- Assignee changed from shyouhei (Shyouhei Urabe) to wyhaines (Kirk Haines)
1.8.7 fixes this at r27406. 1.8.6 should also be fixed.
Updated by wyhaines (Kirk Haines) almost 2 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r28255. Peter, thank you for reporting this issue. Your contribution to Ruby is greatly appreciated. May Ruby be with you.