isJSONEncodedFieldKey matches a wire key the way the DECODER that consumes it does: case-insensitively. encoding/json matches an incoming key to a struct field by an exact match first and a CASE-INSENSITIVE one otherwise, so `{"Fields":...}` and `{"FIELDS":...}` both land in ItemCreate.Fields. A ca
(k string)
| 788 | // rather than a bare map index: the map is the vocabulary, the MATCHING RULE |
| 789 | // belongs to the consumer. |
| 790 | func isJSONEncodedFieldKey(k string) bool { |
| 791 | if jsonEncodedFieldKeys[k] { |
| 792 | return true |
| 793 | } |
| 794 | // EqualFold, not ToLower. encoding/json matches with Unicode SIMPLE |
| 795 | // FOLDING, which is wider than lower-casing: U+017F LATIN SMALL LETTER |
| 796 | // LONG S folds to 's', so "ſchema" reaches the `schema` field while |
| 797 | // strings.ToLower("ſchema") is still "ſchema" and missed the allowlist. |
| 798 | // Fixing the ASCII half and leaving the Unicode half |
| 799 | // would have been this bug's own pattern one more time. |
| 800 | for canonical := range jsonEncodedFieldKeys { |
| 801 | if strings.EqualFold(k, canonical) { |
| 802 | return true |
| 803 | } |
| 804 | } |
| 805 | return false |
| 806 | } |
| 807 | |
| 808 | // nestedDocumentDecodesNUL walks a JSON document carried as a string — an |
| 809 | // item's `fields` blob, a collection's `schema` — for a string containing a |
no outgoing calls