Is "*/xml" a valid value for the Accept field

Hi there,

while working on "Accept-Query" I came across this:

<https://www.rfc-editor.org/rfc/rfc9110.html#field.accept>

>   Accept = #( media-range [ weight ] )
>
>   media-range    = ( "*/*"
>                      / ( type "/" "*" )
>                      / ( type "/" subtype )
>                    ) parameters

So media-range special-cases "*/*" and "type/*", and explains what that
means...

But: type and subtype are defined in
<https://www.rfc-editor.org/rfc/rfc9110.html#media.type> as:

>   media-type = type "/" subtype parameters
>   type       = token
>   subtype    = token

and token is (<https://www.rfc-editor.org/rfc/rfc9110.html#tokens>):

>   token          = 1*tchar
>
>   tchar          = "!" / "#" / "$" / "%" / "&" / "'" / "*"
>                  / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
>                  / DIGIT / ALPHA
>                  ; any VCHAR, except delimiters

So tokens can contain "*".

That makes:

"*/xml"

or

"a*/xml"

or

"application/*json"

... syntactically valid media types (as per RFC 9110).

So, what does this mean?

1) They are invalid, and we should say so (erratum?).

2) They are valid, but except for the cases mentioned for media-range,
they have no wildcard properties.

Looking at <https://www.rfc-editor.org/rfc/rfc6838.html#section-4.2>
though, valid types and subtypes indeed can not contain "*".

So maybe the type/subtype definition in RFC 9110 needs to be fixed,
because it allows values that never are valid media type/subtypes?

Best regards, Julian

Received on Wednesday, 6 November 2024 17:47:05 UTC