Opened 9 years ago

Closed 9 years ago

#1122 closed defect (invalid)

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

Reported by: hipertracker@… Owned by: adrian
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: UI/UX:

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 Changed 9 years ago by eugene@…

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 Changed 9 years ago by rjwittams

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 Changed 9 years ago by hipertracker@…

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 Changed 9 years ago by jacob

  • Resolution set to invalid
  • Status changed from new to closed

This is fixed in trunk.

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