Project

General

Profile

Actions

Bug #5840

closed

URI::MailTo.build - 2 of 3 examples fail on 1.9.2/1.93

Added by primerano (Tony Primerano) almost 13 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 1.9.3dev (2011-07-31 revision 32789) [x86_64-darwin11.1.0]
Backport:
[ruby-core:<unknown>]

Description

The array examples of URI::MailTo.build in the documentation fail on 1.9
http://www.ruby-doc.org/stdlib-1.9.3/libdoc/uri/rdoc/URI/MailTo.html

ex

ruby-1.9.3-preview1 :003 > m2 = URI::MailTo.build(['', [['Subject', 'Ruby'], ['Cc', '']]])
URI::InvalidComponentError: bad component(expected opaque component): ?Subject=["Ruby"]&Cc=[""]
from /Users/primerano/Developer/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/uri/generic.rb:957:in check_opaque' from /Users/primerano/Developer/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/uri/generic.rb:988:in opaque='
from /Users/primerano/Developer/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/uri/generic.rb:198:in initialize' from /Users/primerano/Developer/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/uri/mailto.rb:135:in initialize'
from /Users/primerano/Developer/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/uri/generic.rb:140:in new' from /Users/primerano/Developer/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/uri/generic.rb:140:in build'
from /Users/primerano/Developer/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/uri/mailto.rb:122:in build' from (irb):3 from /Users/primerano/Developer/.rvm/rubies/ruby-1.9.3-preview1/bin/irb:16:in '

ruby-1.9.3-preview1 :004 > m3 = URI::MailTo.build({:to => '', :headers => [['subject', 'subscribe']]})
URI::InvalidComponentError: bad component(expected opaque component): ?subject=["subscribe"]
from /Users/primerano/Developer/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/uri/generic.rb:957:in check_opaque' from /Users/primerano/Developer/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/uri/generic.rb:988:in opaque='
from /Users/primerano/Developer/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/uri/generic.rb:198:in initialize' from /Users/primerano/Developer/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/uri/mailto.rb:135:in initialize'
from /Users/primerano/Developer/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/uri/generic.rb:140:in new' from /Users/primerano/Developer/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/uri/generic.rb:140:in build'
from /Users/primerano/Developer/.rvm/rubies/ruby-1.9.3-preview1/lib/ruby/1.9.1/uri/mailto.rb:122:in build' from (irb):4 from /Users/primerano/Developer/.rvm/rubies/ruby-1.9.3-preview1/bin/irb:16:in '

1st example works fine.
ruby-1.9.3-preview1 :005 > m1 = URI::MailTo.build(['', 'subject=Ruby'])
=> #<URI::MailTo:0x007fb75a025918 URL:?subject=Ruby>

Actions #1

Updated by primerano (Tony Primerano) almost 13 years ago

looking at the code it appears the header items should be a hash instead of an array. It makes for a nicer read

m3 = URI::MailTo.build({:to => '', :headers => {'subject' => 'subscribe', 'body' => 'welcome'}})
=> #<URI::MailTo:0x007fd1632a4c48 URL:?subject=subscribe&body=welcome>

Hoping the docs will be updated instead of the code as I prefer this syntax.

Actions #2

Updated by naruse (Yui NARUSE) almost 13 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r34360.
Tony, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/uri/mailto.rb (URI::MailTo.build): follow Array#to_s change of
    Ruby 1.9; use Array#join. [Bug #5840]
Actions

Also available in: Atom PDF

Like0
Like0Like0