From: duerst@... Date: 2016-03-24T09:42:01+00:00 Subject: [ruby-core:74531] [Ruby trunk Bug#12212] Parsing a URI of "mailto:?subject=hi" with `URI.parse` raises an exception Issue #12212 has been updated by Martin D��rst. Mark Dodwell wrote: > 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. As one of the co-authors of RFC 6068, I have to agree with you. See the first syntax production in https://tools.ietf.org/html/rfc6068#section-2, where the square brackets around 'to' in mailtoURI = "mailto:" [ to ] [ hfields ] indicate that the 'to' part can be omitted. This rule is exactly the same as in RFC 2368 (see https://tools.ietf.org/html/rfc2368#section-2), the predecessor of RFC 6068. Although most 'mailto' URIs will have a 'to' part, it can clearly be useful to have a 'mailto' URI without a 'to' part, e.g. if only cc: and bcc: addressees are present, or for some sample emails where e.g. 'subject' and body are prepared, but each user has to enter the addressees themselves. ---------------------------------------- Bug #12212: Parsing a URI of "mailto:?subject=hi" with `URI.parse` raises an exception https://bugs.ruby-lang.org/issues/12212#change-57655 * Author: Mark Dodwell * Status: Open * Priority: Normal * Assignee: * 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: