From: l.ceslovas@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:98138] [Ruby master Bug#16830] URI.parse raises NoMethodError instead of URI::InvalidURIError
Date: Tue, 05 May 2020 07:58:40 +0000 (UTC) [thread overview]
Message-ID: <redmine.issue-16830.20200505075839.38404@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16830.20200505075839.38404@ruby-lang.org
Issue #16830 has been reported by csk157 (Česlovas Lopan).
----------------------------------------
Bug #16830: URI.parse raises NoMethodError instead of URI::InvalidURIError
https://bugs.ruby-lang.org/issues/16830
* Author: csk157 (Česlovas Lopan)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
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/
next parent reply other threads:[~2020-05-05 7:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-05 7:58 l.ceslovas [this message]
2020-07-23 5:02 ` [ruby-core:99289] [Ruby master Bug#16830] URI.parse raises NoMethodError instead of URI::InvalidURIError nagachika00
2021-04-04 22:27 ` [ruby-core:103213] " usa
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.issue-16830.20200505075839.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).