Skip to content

[Python] parse_media_range overrides quality values of 0 #15

@GoogleCodeExporter

Description

@GoogleCodeExporter
What steps will reproduce the problem?

mimeparse.parse_media_range('*/*;q=0')

Expected Output: ('*', '*', {'q': '0'})
Actual Output: ('*', '*', {'q': '1'})

I encountered this while parsing an request Accept header with
'application/xml,*/*;q=0' and the only acceptable type on the
server is application/json. It freely let the server return a
JSON representation, but should have failed since the user agent
explicitly defined a quality of 0 for all other mimetypes. The
value of 0 for */* was being overwritten with 1.

56c56,57
<             float(params['q']) > 1 or float(params['q']) < 0:

---
>             not float(params['q']) or float(params['q']) > 1\
>             or float(params['q']) < 0:


What version of the product are you using? On what operating system?

Python version of mimeparse 0.1.3
Using Python 2.7.1

Original issue reported on code.google.com by bjr...@gmail.com on 12 Feb 2012 at 2:57

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions