jeremyevans/sequel — pull request #453 by sandys (2012-03-15 05:56:33+00:00)
Title: escaping the password to prevent URI:InvalidcomponentError

1.9.3p0 :002 > db = Sequel.connect("mysql://sandeep:s%40d33p@localhost/db1")
=> #"sandeep", :password=>"s@d33p", :host=>"localhost", :port=>nil, :database=>"db1", :adapter=>"mysql", :disconnection_proc=>#, :adapter_class=>Sequel::MySQL::Database, :single_threaded=>false}>
1.9.3p0 :003 > db.url
URI::InvalidComponentError: bad component(expected user component): s@d33p
from /home/user/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/uri/generic.rb:439:in `check_password'
from /home/user/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/uri/generic.rb:512:in `password='
from /home/user/.rvm/gems/ruby-1.9.3-p0/gems/sequel-3.31.0/lib/sequel/database/misc.rb:215:in `uri'
from /home/user/.rvm/gems/ruby-1.9.3-p0/gems/sequel-3.31.0/lib/sequel/database/misc.rb:221:in `url'
from (irb):3
from /home/user/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `

'

The above error occurs because even though I give Sequel a CGI escaped password, it passes it to the URI gem in its unescaped form.