aspear / mimeparse

Automatically exported from code.google.com/p/mimeparse
MIT License
0 stars 0 forks source link

[Python] parse_media_range overrides quality values of 0 #15

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
Hey, this is fixed in my fork in https://github.com/dbtsai/python-mimeparse

Original comment by dbt...@dbtsai.com on 26 Aug 2012 at 11:32