Subject: [core] #180: Update ABNF for queries

From: "core issue tracker" <[email-masked]>
Date: Mon, 02 Jan 2012 16:25:44 -0000

#180: Update ABNF for queries

 Esko's comments on the link-format document got Zach and me thinking about
 our usage of ptoken again.

 In link-format-09, the syntax for the queries in the URIs says:

        filter-query = resource-param "=" query-pattern
        resource-param = "uri" / parmname
        query-pattern = ptoken [ "*" ]
        ptoken = <Defined in RFC5988>

 Now, 5988 defines ptoken for use in an RFC822-style (RFC2616) header, not
 in a URI.
 Looking more closely:

  ptoken         = 1*ptokenchar
  ptokenchar     = "!" | "#" | "$" | "%" | "&" | "'" | "("
                 | ")" | "*" | "+" | "-" | "." | "/" | DIGIT
                 | ":" | "<" | "=" | ">" | "?" | "@" | ALPHA
                 | "[" | "]" | "^" | "_" | "`" | "{" | "|"
                 | "}" | "~"

 Oops, that actually includes "*" and "&"!
 There also is no mention of percent-encoding (of course not, because
 RFC2616 does not percent-encode headers).

 So what we really want to import here is RFC3986 ABNF, not RFC2616/RFC5988
 ABNF.

 First attempt:

        query-pattern = search-token [ "*" ]
        search-token = *pchar

 But pchar (RFC3986) includes subdelims:

   pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"

   query         = *( pchar / "/" / "?" )

   pct-encoded   = "%" HEXDIG HEXDIG
   unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~"
   sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
                 / "*" / "+" / "," / ";" / "="

 … which includes "*" and "&".

 So, to do this right, let's mix this properly:

        query-pattern = search-token [ "*" ]
        search-token = *search-char
        search-char = unreserved / pct-encoded
                    / ":" / "@"   ; from pchar
                    / "/" / "?"   ; from query
                    / "!" / "$" / "'" / "(" / ")"
                    / "+" / "," / ";" / "="  ; from sub-delims

 :@/?!$'()+,;= indeed.

 This makes it possible to say something like:

 GET /.well-known/core?rt=outdoor%20temperature

 After the percent-decoding defined in core-coap's URI parsing (section
 6.4), the server will see:

 Uri-Path  .well-known
 Uri-Path  core
 Uri-Query rt=outdoor temperature

 which sounds about right.

 The parser in the server will now just have to
 1) search for the first "=" and use that to delimit the parameter name
 from the search-token
 2) check for a trailing "*" and remove that, if present, indicating a
 prefix match.

 Would I use spaces for rt values?  Probably not, but there are still good
 reasons for staying general here.
 As the percent-decoding is already done when the server sees it, there is
 no cost to this generality, either.

 The defnition of query-pattern also needs to be updated.

-- 
-------------------------+--------------------
 Reporter:  zach@…       |      Owner:  zach@…
     Type:  editorial    |     Status:  new
 Priority:  minor        |  Milestone:
Component:  link-format  |    Version:
 Severity:  -            |   Keywords:
-------------------------+--------------------

Ticket URL: <http://trac.tools.ietf.org/wg/core/trac/ticket/180>
core <http://tools.ietf.org/core/>

---

From: "core issue tracker" <[email-masked]>
Date: Mon, 02 Jan 2012 16:41:54 -0000

Changes (by zach@…):

 * status:  new => closed
 * resolution:   => fixed

Comment:

 Done.

-- 
-------------------------+---------------------
 Reporter:  zach@…       |       Owner:  zach@…
     Type:  editorial    |      Status:  closed
 Priority:  minor        |   Milestone:
Component:  link-format  |     Version:
 Severity:  -            |  Resolution:  fixed
 Keywords:               |
-------------------------+---------------------

Ticket URL: <http://trac.tools.ietf.org/wg/core/trac/ticket/180#comment:1>
core <http://tools.ietf.org/core/>