is Accept header BNF ambiguous ?
Anselm Baird-Smith (abaird@w3.org)
Thu, 6 Jun 1996 12:58:53 +0500
I have started writing the parsers for the 1.1 headers, starting with
the beginning, I am trying to parse the Accept header, whose
definition is given by (section 14.1):
Accept = "Accept" ":" #(
media-range
[ ( ":" | ";" )
range-parameter
*( ";" range-parameter ) ]
| extension-token )
media-range = ( "*/*"
| ( type "/" "*" )
| ( type "/" subtype )
) *( ";" parameter )
range-parameter = ( "q" "=" qvalue )
| extension-range-parameter
extension-range-parameter = ( token "=" token )
extension-token = token
FYI, parameter is defined as (section 3.7):
parameter = attribute "=" value
attribute = token
value = token | quoted-string
If the media-range is separated from the range-parameter by a ':',
then I am happy, everything is fine (note that for 1.1 server this is
only a SHOULD, not a MUST, I can't see why). However, if media-range
is separated from range-parameter by a ';' (as some clients did in
HTTP/1.0), then I have no ways to know wether the given parameter is
to be attached to the media-range clause rather then to the
range-parameter one. As far as I understand the problem is that both
the parameter and the range-parameter are extensible.
More pragmatically when I am parsing:
Accept: text/html;x=1;y=2
I have to be able to select one of the following interpretations:
a) media-range=text/html;x=1;y=2
range-paramer=EMPTY
b) media-range=text/html;x=1
range-parameter=y=2
c) media-range=text/html
range-parameter=x=1;y=2
And I don't know how to do it.
Anselm.