From: merch-redmine@... Date: 2019-06-26T22:50:39+00:00 Subject: [ruby-core:93374] [Ruby trunk Bug#12212] Parsing a URI of "mailto:?subject=hi" with `URI.parse` raises an exception Issue #12212 has been updated by jeremyevans0 (Jeremy Evans). Status changed from Open to Closed I can't replicate the `NoMethodError` you are receiving on any ruby version: ``` $ ruby18 -ruri -e 'p URI.parse("mailto:?subject=hi")' # $ ruby19 -ruri -e 'p URI.parse("mailto:?subject=hi")' # $ ruby20 -ruri -e 'p URI.parse("mailto:?subject=hi")' # $ ruby21 -ruri -e 'p URI.parse("mailto:?subject=hi")' # $ ruby22 -ruri -e 'p URI.parse("mailto:?subject=hi")' # $ ruby23 -ruri -e 'p URI.parse("mailto:?subject=hi")' # $ ruby24 -ruri -e 'p URI.parse("mailto:?subject=hi")' # $ ruby25 -ruri -e 'p URI.parse("mailto:?subject=hi")' # $ ruby26 -ruri -e 'p URI.parse("mailto:?subject=hi")' # ``` In the patch, the regexp you are trying to skip (`/\A(?:[^@,;]+@[^@,;]+(?:\z|[,;]))*\z/`) already matches the empty string, and skipping the conditional would prevent a `InvalidComponentError`, it wouldn't affect the `NoMethodError` you received. ---------------------------------------- Bug #12212: Parsing a URI of "mailto:?subject=hi" with `URI.parse` raises an exception https://bugs.ruby-lang.org/issues/12212#change-78897 * Author: madeofcode (Mark Dodwell) * Status: Closed * Priority: Normal * Assignee: * Target version: * ruby -v: trunk * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- Parsing a URI of "mailto:?subject=hi" with `URI.parse` raises an exception. I believe this is a valid "mailto" URI, as defined in RFC6068. Behavior observed: ```ruby >> URI.parse("mailto:?subject=hi") NoMethodError: undefined method `split' for nil:NilClass ``` Behavior expected: ```ruby >> uri = URI.parse("mailto:?subject=hi") => # >> uri.to => "" >> uri.headers => [["subject", "hi"]] ``` Reference from RFC6068 than defines the "to" element as optional: > mailtoURI = "mailto:" [ to ] [ hfields ] > > https://tools.ietf.org/html/rfc6068#section-2 Patch attached. ---Files-------------------------------- fix-uri-mailto-parsing-blank-to-with-query.patch (1.52 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: