Opened 18 years ago

Closed 18 years ago

#1122 closed defect (invalid)

Django do not serve static binary files (e.g. images) correctly

Reported by: hipertracker@… Owned by: Adrian Holovaty
Component: Core (Other) Version: 0.90
Severity: critical Keywords: static files images
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Django do not serve static binary files (e.g. images) correctly

Solution:

django-0.90-py2.4.egg\django\views\static.py line 52:

Change line 52 from:

return HttpResponse(open(fullpath, 'rb').read(), mimetype=mimetype)

to:

return HttpResponse(open(fullpath).read(), mimetype=mimetype)

Change History (4)

comment:1 by eugene@…, 18 years ago

Could you explain what's wrong with the currrent code (1 line)? What kind of effects do you see? What OS and Python version did you use? How do you solve the problem by removing 'rb'? I cannot reproduce the problem.

comment:2 by rjwittams, 18 years ago

It sounds like they have uploaded an image in ASCII mode to their server, so this would end up undoing the damage. User error and should be closed if so....

comment:3 by hipertracker@…, 18 years ago

django v0.9 has line return HttpResponse(open(fullpath).read(), mimetype=mimetype). I found in svn it was corrected. I made a mistake with message, It had to be:
Change line 52 from:
HttpResponse(open(fullpath).read(), mimetype=mimetype)
to
return HttpResponse(open(fullpath, 'rb').read(), mimetype=mimetype)

comment:4 by Jacob, 18 years ago

Resolution: invalid
Status: newclosed

This is fixed in trunk.

Note: See TracTickets for help on using tickets.
Back to Top