URI parsing issues with passwords that include dots in version 1.1.5+ of the Ruby driver

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 1.2.0
    • Affects Version/s: 1.1.5
    • Component/s: None
    • None
    • Environment:
      Mac OS 10.5.8 & Heroku - Rails 3.0.3 - Ruby 1.8.7 & 1.9.2 - mongoid 2.0.0.rc1 - bson_ext 1.1.5
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I can no longer connect to my MongoHQ database using passwords with
      dots in them after upgrading to Mongoid 2.0.0.rc1, with the 1.1.5
      version of the MongoDB Ruby driver. The issue is the
      MONGODB_URI_MATCHER in 'lib/mongo/util/uri_parser.rb'.

      I've tested this both on my local dev machine and on two Heroku instances. Here is the URI (changed user and pass, but kept the same format):

      mongodb://username:AB.1234@arrow.mongohq.com:27081/appname-staging

      Here is the stack trace from one of my Heroku instances (which reflects the error on my local dev machine):

      /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/mongo-1.1.5/lib/../lib/mongo/util/uri_parser.rb:53:in `parse': Invalid port AB; port must be specified as digits. (Mongo::MongoArgumentError)
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/mongo-1.1.5/lib/../lib/mongo/util/uri_parser.rb:42:in `each'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/mongo-1.1.5/lib/../lib/mongo/util/uri_parser.rb:42:in `parse'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/mongo-1.1.5/lib/../lib/mongo/connection.rb:143:in `from_uri'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/mongoid-2.0.0.rc.1/lib/mongoid/config/database.rb:86:in `master'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/mongoid-2.0.0.rc.1/lib/mongoid/config/database.rb:19:in `configure'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/mongoid-2.0.0.rc.1/lib/mongoid/config.rb:318:in `configure_databases'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/mongoid-2.0.0.rc.1/lib/mongoid/config.rb:108:in `from_hash'
      from (eval):2:in `send'
      from (eval):2:in `from_hash'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/mongoid-2.0.0.rc.1/lib/mongoid/railtie.rb:54
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `run_initializers'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `send'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
      from /disk1/home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/config/environment.rb:5
      from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
      from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
      from config.ru:3
      from /home/heroku_rack/heroku.ru:23
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/rack-1.2.1/lib/rack/builder.rb:46:in `instance_eval'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/rack-1.2.1/lib/rack/builder.rb:46:in `initialize'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/rack-1.2.1/lib/rack/builder.rb:63:in `new'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/rack-1.2.1/lib/rack/builder.rb:63:in `map'
      from /home/heroku_rack/heroku.ru:18
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/rack-1.2.1/lib/rack/builder.rb:46:in `instance_eval'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/rack-1.2.1/lib/rack/builder.rb:46:in `initialize'
      from /home/heroku_rack/heroku.ru:11:in `new'
      from /home/heroku_rack/heroku.ru:11
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/rack-1.2.1/lib/rack/builder.rb:46:in `instance_eval'
      from /home/slugs/fa4dab45-9307-4659-83e2-80826e41652a/mnt/.bundle/gems/ruby/1.8/gems/rack-1.2.1/lib/rack/builder.rb:46:in `initialize'
      from /home/heroku_rack/heroku.ru:1:in `new'
      from /home/heroku_rack/heroku.ru:1

      I tested the following change locally.

      MONGODB_URI_MATCHER = /(([-_.\w\d])[-_\w\d])@)?([-.\w\d]+)([\w\d]
      ))?(\/([-\d\w]))?/

      to

      MONGODB_URI_MATCHER = /(([-_.\w\d])[-_.\w\d])@)?([-.\w\d]+)([\w
      \d]))?(\/([-\d\w]))?/

      It resolved my issue. I can't test this out on Heroku.

            Assignee:
            Kyle Banker (Inactive)
            Reporter:
            Mike Clymer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: