ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: usa@garbagecollect.jp
To: ruby-core@ruby-lang.org
Subject: [ruby-core:103213] [Ruby master Bug#16830] URI.parse raises NoMethodError instead of URI::InvalidURIError
Date: Sun, 04 Apr 2021 22:27:39 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-91287.20210404222739.38404@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16830.20200505075839.38404@ruby-lang.org

Issue #16830 has been updated by usa (Usaku NAKAMURA).

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.

----------------------------------------
Bug #16830: URI.parse raises NoMethodError instead of URI::InvalidURIError
https://bugs.ruby-lang.org/issues/16830#change-91287

* Author: csk157 (Česlovas Lopan)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
* Backport: 2.5: REQUIRED, 2.6: DONE, 2.7: DONE
----------------------------------------
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)
```




-- 
https://bugs.ruby-lang.org/

      parent reply	other threads:[~2021-04-04 22:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-05  7:58 [ruby-core:98138] [Ruby master Bug#16830] URI.parse raises NoMethodError instead of URI::InvalidURIError l.ceslovas
2020-07-23  5:02 ` [ruby-core:99289] " nagachika00
2021-04-04 22:27 ` usa [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-91287.20210404222739.38404@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).