w3c / did-core

W3C Decentralized Identifier Specification v1.0
https://www.w3.org/TR/did-core/
Other
404 stars 94 forks source link

Adding % (percent) character to the 'idchar' ABNF rule of DID URIs #699

Closed dmitrizagidulin closed 3 years ago

dmitrizagidulin commented 3 years ago

Although the current idchar DID URI ABNF rule is inspired by RFC3986 URI Syntax, it is more tightly constrained, and prevents the implementation of a couple of crucial encoding use cases.

This came up in the development and implementation of the did:web DID Method spec with @awoie and others, although I expect this issue to affect other DID methods as well. Specifically, the current DID URI ABNF rules don't allow for did-method-specific strings to contain data encoded in various key formats (base64url encoding (no = char allowed), Punycode encoding (several ASCII chars not allowed), or Percent-encoding).

Proposal: Let's add the % character to the idchar ABNF rule which currently reads:

idchar = ALPHA / DIGIT / "." / "-" / "_"

to be:

idchar = ALPHA / DIGIT / "." / "-" / "_"/ "%"

This will enable DID Methods to perform Percent encoding (which then enables base64url encoding of binary data, Punycode encoding of Unicode international characters, and others).

OR13 commented 3 years ago

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

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

For consistency, percent-encoded octets in the ranges of ALPHA (%41-%5A and %61-%7A), DIGIT (%30-%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should not be created by URI producers and, when found in a URI, should be decoded to their corresponding unreserved characters by URI normalizers.

peacekeeper commented 3 years ago

I think this makes sense, but should we perhaps do:

idchar = ALPHA / DIGIT / "." / "-" / "_" / pct-encoded
pct-encoded   = "%" HEXDIG HEXDIG

... in order to only allow % encoding in a URI-compatible way, not for arbitrary use?

peacekeeper commented 3 years ago

@talltree also needs to review this.

awoie commented 3 years ago

IMO, % is a very useful addition, so +1.

msporny commented 3 years ago

PR #703 has been raised to address this issue. This issue will be closed once PR #703 is merged.

msporny commented 3 years ago

PR #703 has been merged, closing.