Re: [web-nfc] reg-name ABNF is unspecified (#350)

Thanks @sleevi for the helpful insights, almost each of which uncovers bugs in the spec.

> Is 255 bytes a limit from NFC-RTD? 

It comes from the NDEF spec. Type length field is 8 bits, which limits type field to 255 bytes (octets).
Any encoding must fit in this space. Underlying platforms should take care of truncating or throwing away input longer than this, so this is just a safety step here.

> My understanding is that type MUST NOT contain `'U+003A (:)`, that this comes from the NFC-RTD specification, and so there's no risk of a type being domain.example:foo:bar with the intended domain of domain.example and the intended type of foo:bar, right?

A good observation, and yeah, welcome to the hive :). I try to summarize the main things. The  NFC RTD says:

> Record type names SHALL be formed of characters from of the US ASCII character set.
Characters in the range [0-31] and 127 decimal SHALL NOT be used in record type names.
(...)
Record type names may be specified in several formats, called Type Name Formats, as signified
by the TNF field of the NDEF record header. 

Out of these, the NFC RTD defines the format for the NFC Forum standardized type names.
There is some confusion there. The RTD spec mandates type names be a URN ([RFC 2141], with the namespace identifier “nfc”, namespace specific string "wkt:". However, when encoded in an NDEF message, the Well Known Type MUST be written as a relative-URI construct [RFC 3986], omitting the NID and the “wkt:” prefix. 

The ABNF for RTD type names takes the _first_ occurrence of US-ASCII `:` as delimiter between `dns-part` and `name-part` of an external type name. The RTD spec allows `:` in the `name-part`. 
This would allow `domain.example:foo:bar` with `dns-part` being `domain.example` and `name-part` being `foo:bar`.

However, the NDEF spec says the literal format for IPv6 addresses in URIs as described by RFC
2732 SHOULD be supported.

Since we have a conflict here, we made the choice of disallowing `:` in the `name-part` and take the _last_ occurrence of `:` as delimiter, which IIRC was done as quick fix to a review comment. 

Probably what we should do instead is figure out if `dns-part` is literal IPv6 and take the first `:` as delimiter after it, allowing `:` in the `name-part` of external types. I will update the validation algorithm.

-- 
GitHub Notification of comment by zolkis
Please view or discuss this issue at https://github.com/w3c/web-nfc/issues/350#issuecomment-570529776 using your GitHub account

Received on Friday, 3 January 2020 10:19:05 UTC