mjackson / rack-accept

HTTP Accept* for Ruby/Rack
http://mjackson.github.com/rack-accept
47 stars 16 forks source link

incorrect parsing of media-ranges etc #3

Closed SSDany closed 14 years ago

SSDany commented 14 years ago

accept-extension: m = Rack::Accept::MediaType.new('text/_;q=0.5;a=42')

<Rack::Accept::MediaType:0x101706d70 @qvalues={"text/_;q=0.5;a=42"=>1}>

malformed qvalues: m = Rack::Accept::MediaType.new('text/_;q=42')

<Rack::Accept::MediaType:0x101700290 @qvalues={"text/_"=>42.0}>

mjackson commented 14 years ago

The first example above is invalid according to the spec:

The first "q" parameter (if any) separates the media-range parameter(s) from the accept-params.

The "a" parameter is invalid. The second example is also not valid according to the spec:

A weight is normalized to a real number in the range 0 through 1, where 0 is the minimum and 1 the maximum value.

42 is not a valid qvalue.