@@ -319,19 +319,23 @@ def render(template_name, value, **context):
319
319
.. todo:: Adding :mailheader:`Vary` header.
320
320
321
321
"""
322
- accept_mimetypes = flask .request .accept_mimetypes
323
- if len (accept_mimetypes ) == 1 and accept_mimetypes .values ()[0 ] == '*/*' :
324
- accept_mimetypes = [(default_content_type , 1 )]
325
- accept_mimetypes = werkzeug .datastructures .MIMEAccept (accept_mimetypes )
326
322
jinja_env = flask .current_app .jinja_env
327
323
def _tpl_avail (postfix ):
328
324
try :
329
325
jinja_env .get_template (template_name + postfix )
330
326
except jinja2 .TemplateNotFound :
331
327
return False
332
328
return True
333
- types = (mimetype for mimetype , f in content_types .iteritems ()
334
- if callable (f ) or not f .startswith ('.' ) or _tpl_avail (f ))
329
+ types = [mimetype for mimetype , f in content_types .iteritems ()
330
+ if callable (f ) or not f .startswith ('.' ) or _tpl_avail (f )]
331
+ # workaround for IE8. it sent wrong Accept header like below -_-
332
+ # " Accept: image/pjpeg, image/pjpeg, image/gif, image/jpeg, */* "
333
+ m = ((mime , q ) for mime , q in flask .request .accept_mimetypes
334
+ if mime in types or mime == '*/*' )
335
+ accept_mimetypes = werkzeug .datastructures .MIMEAccept (m )
336
+ if len (accept_mimetypes ) == 1 and accept_mimetypes .values ()[0 ] == '*/*' :
337
+ accept_mimetypes = [(default_content_type , 1 )]
338
+ accept_mimetypes = werkzeug .datastructures .MIMEAccept (accept_mimetypes )
335
339
content_type = accept_mimetypes .best_match (types )
336
340
try :
337
341
serializer = content_types [content_type ]
0 commit comments