Skip to content

Commit

Permalink
Use MIMEAccept instead of Accept
Browse files Browse the repository at this point in the history
Accept does not take into account type/subtype, and thus could
potentially return the wrong result to a client if they send a funky
Accept header.

Closes #240
  • Loading branch information
digitalresistor committed Apr 14, 2016
1 parent 5c89119 commit 37a8aca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions webob/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
import re
import sys

from webob.acceptparse import Accept
from webob.acceptparse import MIMEAccept
from webob.compat import (
class_types,
text_,
Expand Down Expand Up @@ -327,9 +327,9 @@ def generate_response(self, environ, start_response):
del self.content_length
headerlist = list(self.headerlist)
accept_value = environ.get('HTTP_ACCEPT', '')
accept = Accept(accept_value)
match = accept.best_match(['application/json', 'text/html',
'text/plain'], default_match='text/plain')
accept = MIMEAccept(accept_value)
if match == 'text/html':
content_type = 'text/html'
body = self.html_body(environ)
Expand Down

0 comments on commit 37a8aca

Please sign in to comment.