Project

General

Profile

Actions

Bug #16830

closed

URI.parse raises NoMethodError instead of URI::InvalidURIError

Added by csk157 (Česlovas Lopan) over 4 years ago. Updated over 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
[ruby-core:98138]

Description

When parsing an invalid uri using URI.parse it is possible to get NoMethodError (undefined method []' for nil:NilClass). I would expect URI::InvalidURIError` or similar.

Example with a trace:

irb(main):002:0> URI.parse("ldaps:https://example.com")
Traceback (most recent call last):
       10: from /Users/clopan/.rbenv/versions/2.7.1/bin/irb:23:in `<main>'
        9: from /Users/clopan/.rbenv/versions/2.7.1/bin/irb:23:in `load'
        8: from /Users/clopan/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/irb-1.2.3/exe/irb:11:in `<top (required)>'
        7: from (irb):1
        6: from (irb):2:in `rescue in irb_binding'
        5: from /Users/clopan/.rbenv/versions/2.7.1/lib/ruby/2.7.0/uri/common.rb:234:in `parse'
        4: from /Users/clopan/.rbenv/versions/2.7.1/lib/ruby/2.7.0/uri/rfc3986_parser.rb:76:in `parse'
        3: from /Users/clopan/.rbenv/versions/2.7.1/lib/ruby/2.7.0/uri/rfc3986_parser.rb:76:in `new'
        2: from /Users/clopan/.rbenv/versions/2.7.1/lib/ruby/2.7.0/uri/ldap.rb:116:in `initialize'
        1: from /Users/clopan/.rbenv/versions/2.7.1/lib/ruby/2.7.0/uri/ldap.rb:122:in `parse_dn'
NoMethodError (undefined method `[]' for nil:NilClass)
Actions #1

Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • Status changed from Open to Closed
  • Backport changed from 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN to 2.5: REQUIRED, 2.6: REQUIRED, 2.7: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) over 4 years ago

  • Backport changed from 2.5: REQUIRED, 2.6: REQUIRED, 2.7: REQUIRED to 2.5: REQUIRED, 2.6: REQUIRED, 2.7: DONE

ruby_2_7 4f714939efde6d6b3b74c09e1e151e6ce6818b90 merged revision(s) e04418bb16cd99b4a4402e7457d3bdc967284f98.

Updated by usa (Usaku NAKAMURA) over 3 years ago

  • Backport changed from 2.5: REQUIRED, 2.6: REQUIRED, 2.7: DONE to 2.5: REQUIRED, 2.6: DONE, 2.7: DONE

ruby_2_6 r67914 merged revision(s) e04418bb16cd99b4a4402e7457d3bdc967284f98.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0