Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
proto: fix parse of arbitrary keys in pres. syntax
Previously the `FromStr` impl for `SvcParamKey` had support for parsing the "arbitrary key" presentation syntax where a key can be specified "keyNNNNN", where NNNNN is the numeric value of the key type without leading zeros. The existing code would pull out the numeric component into a `u16` and then use the `TryFrom<u16>` impl for `SvcParamKey` to get the key. However, the `TryFrom<u16>` impl for `SvcParamKey` was using the IANA service parameter keys registry to map from u16s to `SvcParamKey`. Values 0..6 are mapped to the known key entries. The reserved range (65280-65534) was mapped to `SvcParamKey::Key`, and 65535 was mapped to `SvcParamKey::Key65535`. This makes sense when mapping an arbitrary u16, but when we are parsing a "keyNNNNN" presentation syntax item, we want to represent it as `Key(NNNNN)`, no matter if it is/isn't a registered key. This commit fixes this behaviour, constructing a `SvcParamKey::Key()` entry when parsing the arbitrary key presentation syntax, avoiding `TryFrom<u16>`. With this change in place the two arbitrary key test vectors can be included in the svcb test vector unit test. [0] https://datatracker.ietf.org/doc/html/rfc9460#name-initial-contents
- Loading branch information