Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] parse_media_range overrides quality values of 0 #15

Open
GoogleCodeExporter opened this issue Feb 9, 2016 · 1 comment
Open

Comments

@GoogleCodeExporter
Copy link

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 [email protected] on 12 Feb 2012 at 2:57

@GoogleCodeExporter
Copy link
Author

Hey, this is fixed in my fork in https://github.com/dbtsai/python-mimeparse

Original comment by [email protected] on 26 Aug 2012 at 11:32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant