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

9110 references 2046, so it's clear we're tying into the media types registry as the source of truth here.

6838 defines the requirements for registration, and <https://www.rfc-editor.org/rfc/rfc6838.html#section-4.2> says:

~~
type-name = restricted-name
restricted-name = restricted-name-first *126restricted-name-chars
restricted-name-first = ALPHA / DIGIT
restricted-name-chars = ALPHA / DIGIT / "!" / "#" /
"$" / "&" / "-" / "^" / "_"
restricted-name-chars =/ "." ; Characters before first dot always
; specify a facet name
restricted-name-chars =/ "+" ; Characters after last plus always
; specify a structured syntax suffix

Note that this syntax is somewhat more restrictive than what is
allowed by the ABNF in Section 5.1 of [RFC2045] or Section 4.2 of
[RFC4288]. Also note that while this syntax allows names of up to
127 characters, implementation limits may make such long names
problematic. For this reason, <type-name> and <subtype-name> SHOULD
be limited to 64 characters.
~~~

> On 6 Nov 2024, at 5:46 PM, Julian Reschke <julian.reschke@gmx.de> wrote:
> 
> 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
> 

--
Mark Nottingham   https://www.mnot.net/

Received on Thursday, 7 November 2024 09:50:36 UTC