Skip to content

Commit 78dcb4d

Browse files
committed
Finish revamping contentEncoding
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 679ec85 commit 78dcb4d

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

content/2020-12/content/contentEncoding.markdown

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ such picture, while setting the `Content-Transfer-Encoding` header to `base64`.
5858

5959
{{</learning-more>}}
6060

61-
[RFC 2045](https://datatracker.ietf.org/doc/html/rfc2045) _(Format of Internet
62-
Message Bodies)_ defines the following standard encodings. In the interest of
61+
[RFC 4648](https://datatracker.ietf.org/doc/html/rfc4686) _(The Base16, Base32,
62+
and Base64 Data Encodings)_ and [RFC
63+
2045](https://datatracker.ietf.org/doc/html/rfc2045) _(Format of Internet
64+
Message Bodies)_ define the following standard encodings. In the interest of
6365
interoperability, avoid defining new content encodings. While the JSON Schema
6466
specification does not provide explicit guidance on this, [RFC 2045 Section
6567
6.3](https://datatracker.ietf.org/doc/html/rfc2045#section-6.3) suggests that
@@ -68,31 +70,43 @@ For example, `x-my-new-encoding`.
6870

6971
| Encoding | Description | Reference |
7072
|------------|-------------------------------------------------------------------------------------------------|-----------|
73+
| `"base64"` | Encoding scheme using a 64-character hexadecimal alphabet | [RFC 4648 Section 4](https://datatracker.ietf.org/doc/html/rfc4648#section-4) |
74+
| `"base32"` | Encoding scheme using a 32-character hexadecimal alphabet | [RFC 4648 Section 6](https://datatracker.ietf.org/doc/html/rfc4648#section-6) |
75+
| `"base16"` | Encoding scheme using a 16-character hexadecimal alphabet | [RFC 4648 Section 8](https://datatracker.ietf.org/doc/html/rfc4648#section-8) |
7176
| `"7bit"` | Encoding scheme that constrains ASCII to disallow octets greater than 127, disallow `NUL`, and restricts `CR` and `LF` to `CRLF` sequences | [RFC 2045 Section 2.7](https://datatracker.ietf.org/doc/html/rfc2045#section-2.7) |
7277
| `"8bit"` | Encoding scheme that constrains ASCII to permit octets greater than 127, disallow `NUL`, and restrict `CR` and `LF` to `CRLF` sequences | [RFC 2045 Section 2.8](https://datatracker.ietf.org/doc/html/rfc2045#section-2.8) |
7378
| `"binary"` | Encoding scheme where any sequence of octets is allowed | [RFC 2045 Section 2.9](https://datatracker.ietf.org/doc/html/rfc2045#section-2.9) |
7479
| `"quoted-printable"` | Encoding scheme that preserves ASCII printable characters and escapes the rest using a simple algorithm based on an hexadecimal alphabet | [RFC 2045 Section 6.7](https://datatracker.ietf.org/doc/html/rfc2045#section-6.7) |
75-
| `"base64"` | Encoding scheme using a 64-character hexadecimal alphabet | [RFC 2045 Section 6.8](https://datatracker.ietf.org/doc/html/rfc2045#section-6.8) |
80+
81+
{{<constraint-warning `string`>}}
7682

7783
## Examples
7884

79-
{{<schema `Schema with 'contentEncoding' keyword`>}}
85+
{{<schema `A schema that describes arbitrary data encoded using Base 64`>}}
8086
{
8187
"$schema": "https://json-schema.org/draft/2020-12/schema",
8288
"contentEncoding": "base64"
8389
}
8490
{{</schema>}}
8591

86-
{{<instance-pass `A properly encoded base64 string is valid`>}}
87-
"SGVsbG8gV29ybGQ=" // --> Hello World (base64 encoded)
92+
{{<instance-pass `A string value encoded in Base 64 is valid and an annotation is emitted`>}}
93+
"SGVsbG8gV29ybGQ=" // Hello World
8894
{{</instance-pass>}}
8995

90-
{{<instance-pass `An incorrectly encoded base64 string is also valid`>}}
91-
"This is not base64 encoded!"
96+
{{<instance-annotation>}}
97+
{ "keyword": "/contentEncoding", "instance": "", "value": "base64" }
98+
{{</instance-annotation>}}
99+
100+
{{<instance-pass `A string value that does not represent a Base 64 encoded value is valid and an annotation is still emitted`>}}
101+
"This is not Base 64"
92102
{{</instance-pass>}}
93103

94-
{{<instance-pass `'contentEncoding' is irrelevant for instances with values other than strings`>}}
95-
[ "foo", "bar" ]
104+
{{<instance-annotation>}}
105+
{ "keyword": "/contentEncoding", "instance": "", "value": "base64" }
106+
{{</instance-annotation>}}
107+
108+
{{<instance-pass `A non-string value is valid but (perhaps counter-intuitively) an annotation is still emitted`>}}
109+
1234
96110
{{</instance-pass>}}
97111

98112
{{<instance-annotation>}}

0 commit comments

Comments
 (0)