Re: [apps-discuss] Scope of RFC3986 and successor - what is a URI?

<darrel.miller@gmail.com> Fri, 16 January 2015 16:11 UTC

Return-Path: <darrel.miller@gmail.com>
X-Original-To: apps-discuss@ietfa.amsl.com
Delivered-To: apps-discuss@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 8AF711ACDDC for <apps-discuss@ietfa.amsl.com>; Fri, 16 Jan 2015 08:11:16 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.016
X-Spam-Level:
X-Spam-Status: No, score=-1.016 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, HTML_FONT_FACE_BAD=0.981, HTML_MESSAGE=0.001, NORMAL_HTTP_TO_IP=0.001, SPF_PASS=-0.001, WEIRD_PORT=0.001] autolearn=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3A6bYSGNSAn3 for <apps-discuss@ietfa.amsl.com>; Fri, 16 Jan 2015 08:11:13 -0800 (PST)
Received: from mail-qg0-x229.google.com (mail-qg0-x229.google.com [IPv6:2607:f8b0:400d:c04::229]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 1E7F81ACE71 for <apps-discuss@ietf.org>; Fri, 16 Jan 2015 08:11:09 -0800 (PST)
Received: by mail-qg0-f41.google.com with SMTP id e89so16949616qgf.0 for <apps-discuss@ietf.org>; Fri, 16 Jan 2015 08:11:08 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:mime-version:from:to:cc:subject:importance:date :in-reply-to:references:content-type; bh=93OOdxSHVnQQqyJVztrBq49KOsaszCSWgTCT7XJc4n0=; b=TEDX35MFA2sclr6iKNiW9BJiPwJpPKVZJasevqK9YcodnYClwYalCgAjr2uMTF8m5x KXMZJl0m8cKtsAIVIENlbvJ+B2+lIA1KsguiUzMmlVYeUFmVniIZAmZxgOgD8cPOQoZ4 7nd16q97Xj+0f04EaJJHAOIR/qPwLC775NHEC39avvhOZh6zCA+gsCvErnbDbhndd+ED qDJYuDmyK4Wg95yhjfl0iMG7XBpGLXxG0S0/xIXxAHkQpY5DSwO5uF5VDG8xznJuchUk PVs7e7lkEvJNbbdjafri+Kl+WVdTaU3AdZJVo6XdRYwPKoeyeu08g2yTOtb5Ow8+6mEv VFLQ==
X-Received: by 10.229.249.137 with SMTP id mk9mr26396638qcb.4.1421424668218; Fri, 16 Jan 2015 08:11:08 -0800 (PST)
Received: from Pecan (bas11-montreal02-1128535737.dsl.bell.ca. [67.68.22.185]) by mx.google.com with ESMTPSA id r12sm4487707qax.38.2015.01.16.08.11.06 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Jan 2015 08:11:07 -0800 (PST)
Message-ID: <54b9381b.8ca1e00a.243f.ffffcae4@mx.google.com>
MIME-Version: 1.0
From: darrel.miller@gmail.com
To: Dave Cridland <dave@cridland.net>, Sam Ruby <rubys@intertwingly.net>
Importance: Normal
Date: Fri, 16 Jan 2015 16:05:44 +0000
In-Reply-To: <CAKHUCzzN4Eu6R_f2Sf8EtiAp-8w3ds5Yp3-PBHK+B0wGRxEtmw@mail.gmail.com>
References: <20140926010029.26660.82167.idtracker@ietfa.amsl.com> <54A557E1.6050502@intertwingly.net> <CACweHNCQZg1U1u8U=-f6h0+BPnp6Wr_T=r_wGiPAbhTbuMCGWQ@mail.gmail.com> <54A94109.5010901@intertwingly.net> <00cf01d02cc7$d5dba4c0$4001a8c0@gateway.2wire.net> <54B16C2B.9050604@seantek.com> <54B17BBE.4000900@intertwingly.net> <54B18B61.8010308@seantek.com> <54B19435.8070401@intertwingly.net> <54B1B211.3050807@seantek.com> <54B1B682.3070609@intertwingly.net> <012001d02d91$6ec42300$4001a8c0@gateway.2wire.net> <54B2781C.4040505@intertwingly.net> <018e01d02dc6$1d03b0a0$4001a8c0@gateway.2wire.net> <54B2CC75.5080900@intertwingly.net> <54B79930.3070009@ninebynine.org> <54B7AEC2.9010109@intertwingly.net> <CAKHUCzz=jZAF-i2_pwGpkER5vNhv95CMwdBCMwigPJ0FA_t4_A@mail.gmail.com> <54B7BD4A.1090803@intertwingly.net> <54B7CF28.7060408@gmx.de> <54B7D605.2060307@intertwingly.net> <f5boaq0gdw5.fsf@troutbeck.inf.ed.ac.uk> <54B806A2.8020803@intertwingly.net>, <CAKHUCzzN4Eu6R_f2Sf8EtiAp-8w3ds5Yp3-PBHK+B0wGRxEtmw@mail.gmail.com>
Content-Type: multipart/alternative; boundary="_53EBFE67-6DDA-44A9-9EE8-447F0D5F1BD5_"
Archived-At: <http://mailarchive.ietf.org/arch/msg/apps-discuss/A7ztS1XxvPCtb0zC-hn6B906biE>
Cc: IETF Apps Discuss <apps-discuss@ietf.org>
Subject: Re: [apps-discuss] Scope of RFC3986 and successor - what is a URI?
X-BeenThere: apps-discuss@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: General discussion of application-layer protocols <apps-discuss.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/apps-discuss>, <mailto:apps-discuss-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/apps-discuss/>
List-Post: <mailto:apps-discuss@ietf.org>
List-Help: <mailto:apps-discuss-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/apps-discuss>, <mailto:apps-discuss-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 16 Jan 2015 16:11:16 -0000

>>Sam Ruby wrote:

>>
>>An example of something that is not a conforming URL, but is both a valid URI and a valid IRI:
>>
>>  http://257.257.257.257/
>


>Dave Cridland wrote:


>OK... I don't think that's valid, but it's probably valid according to the ABNF only (ignoring the prose). I think >specifying that in the formal syntax would be uncontentious - in fact, draft-ietf-iri-3987bis-13 already makes >this change.


It is not even valid based on the ABNF, due to a fairly creative definition of dec-octet.


https://tools.ietf.org/html/rfc3986#section-3.2.2


Darrel






From: Dave Cridland
Sent: ‎Thursday‎, ‎January‎ ‎15‎, ‎2015 ‎5‎:‎09‎ ‎PM
To: Sam Ruby
Cc: IETF Apps Discuss







On 15 January 2015 at 18:27, Sam Ruby <rubys@intertwingly.net> wrote:

Good question.  Please forgive the lengthy answer.






Lengthy is fine.

 

Lets posit the existence of a W_URL parser.  Given a string, it produces an object.  One of the operations that object performs is "stringification" (an IDL term that I don't particularly care for which essentially means serialization to a string form).

 - - -

If you look at the sequence of operations: parse followed by stringification, you get a string transformation.

This can be an identity transform.  If you want, try the following in Firefox or Chrome's console:

  new URL('http://example.com/').href == 'http://example.com/'

The result will be true.

The result can be some transformation.  For example:

  new URL('HTTP://EXAMPLE.COM/PATH').href == 'http://example.com/PATH'

Finally, the result can be to give up.

  new URL('http://example.com:port/')

Both Firefox and Chrome throw an exception.

 - - -

Now if you take a look at that transformation, we can discuss the what should be desirable characteristics of the set of outputs.

The first characteristic that I would like to suggest is that the outputs round trip, and by that I mean that if you feed that output back into the transformation, you get the same result back.






OK; you're saying that for any URL string S, new URL(new URL(S).href).href == new URL(S).href




Your tests seem to imply that for any URL string S, there is one and only one correct value of (new URL(S).href); is that also the case?




To put it another way, your tests imply a canonical form for a URI, and that seems much more useful.

 

The second characteristic is that it actually works.  This isn't a precisely specified criteria, but it means that if you attempt to use the result it doesn't break anything.  One example of this would be placing the string 'http://ietf.org/' into the href attribute of an HTML <a> element, rendering it on the screen, and having somebody click on the link.  If this goes to the right place, then all is good.  The definition of "works" for data: W-URLs, and for javascript: W-URLs are different, but that's not an obstacle at this level of discussion.






I can readily appreciate the sentiment here; like many things, it's hard to specify. But what you're saying is that for any URL string S, where (new URL(S).href) does not produce an error, the result must be a semantically valid URL string? (i'm being delightfully wooly about "semantically valid").

 

 - - -

At this point, I'm troubled.  Despite the set of desirable characteristics I have specified, I have a well defined set which is neither a superset of I-URI's nor I-IRI's, nor a proper subset of either.

An example of something that is not a conforming URL, but is both a valid URI and a valid IRI:

  http://257.257.257.257/






OK... I don't think that's valid, but it's probably valid according to the ABNF only (ignoring the prose). I think specifying that in the formal syntax would be uncontentious - in fact, draft-ietf-iri-3987bis-13 already makes this change.




Similarly, http://127.0.0.1:65536/ is also not valid, but because the concept of port is not tied to a specific transport protocol, and might not be restricted to a 16-bit range, that's a harder one to capture in pure ABNF - that is, the permissable values of port are arguably scheme specific.




Both these are issues of what I called semantic validity above. Others probably exist.

 

Here is something that round-trips a URL parse/stringify transformation, and actually works, despite being an invalid URI and invalid IRI:

  https://www.google.com/?q=[z]






My gut feeling is that allowing this to be valid is a possible change, as I've said. I appreciate this is at odds with RFC 3986, but if URL parsers do generally ignore the error that's fine.

 

To further compound this, RFC 3986 claims that the following strings are to be treated as equivalent (and perhaps even preferred as they are deemed to be 'valid'):

  https://www.google.com/?q=%5Bz%5D
  https://www.google.com/?q=%5bz%5d

Indeed in many, and generally most, situations, those are considered equivalent.  But this is not necessarily so.  To it's credit RFC 3986 does describe a Comparison Ladder.  Unfortunately it does so using terms like "false positives" and "false negatives" when in fact, they aren't false at all.






I think that this would disappear, largely, with a canonical form. RFC 3986 currently says that pct-encoded should use upper case - that's a lower case "should" - and if we take this to be a canonical form, then the latter canonicalizes to the former, and we win. Of course, if [] is made legal in the query string it'd canonicalize to the previous example.




Comparison of URIs then become a case of comparing the canonicalized versions of both.




This is problematic in the case of ports - since http://www.google.com:80/ and http://www.google.com/ both refer to the same thing, but to have a single canonical form for both would require the parser to be aware of the default port for the scheme. But maybe unknown schemes cannot be canonicalized, or maybe we have two canonical forms. (Scheme-aware and scheme-agnostic; obviously you'd specify which you want and where).

 

 - - -

So much for a deep dive.  Returning to the surface: I'd like to simultaneously loosen up the definition of validity for I-URI's in some places while tightening it up in others.  This is a work in progress, so which I can't say exactly where just yet in each case, I can say that now would be a good time for interested parties to participate.


ht


- Sam Ruby


[1] https://url.spec.whatwg.org/, as of 2015-01-15




 _______________________________________________
apps-discuss mailing list
apps-discuss@ietf.org
https://www.ietf.org/mailman/listinfo/apps-discuss