Code

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#896 closed defect (fixed)

[patch] Error serving media files throught django development server on windows

Reported by: Petar Marić <petar.maric@…> Owned by: adrian
Component: Core (Other) Version: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Symptoms: unable to serve media files on windows, getting a large number of 302 redirects

Problem: It seems that something is replacing slashes with backslashes in the url as shown in django-admins runserver log:

[24/Nov/2005 09:15:23] "GET /media/css/print.css HTTP/1.1" 302 0
[24/Nov/2005 09:15:23] "GET /media/css/css%5Cprint.css HTTP/1.1" 302 0
[24/Nov/2005 09:15:23] "GET /media/css/css%5Cprint.css HTTP/1.1" 302 0
[24/Nov/2005 09:15:23] "GET /media/css/css%5Cprint.css HTTP/1.1" 302 0
...

Solution: replace backslashes in newpath with slashes

Patch:

Index: static.py
===================================================================
--- static.py	(revision 1396)
+++ static.py	(working copy)
@@ -34,7 +34,7 @@
         if part in (os.curdir, os.pardir):
             # strip '.' amd '..' in path
             continue
-        newpath = os.path.join(newpath, part)
+        newpath = os.path.join(newpath, part).replace('\\', '/')
     if newpath and path != newpath:
         return HttpResponseRedirect(newpath)
     fullpath = os.path.join(document_root, newpath) 

Credits: nesh for helping me create this patch

Attachments (0)

Change History (3)

comment:1 Changed 8 years ago by sune.kirkeby@…

That should be:

-        newpath = os.path.join(newpath, part)
+        newpath = '/'.join(newpath, part)

comment:2 Changed 8 years ago by adrian

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

(In [1402]) Fixed #896 -- Fixed error in filesystem serve view in Windows. Thanks, Petar Mari?\196?\135 and nesh

comment:3 Changed 8 years ago by adrian

  • milestone Version 0.91 deleted

Milestone Version 0.91 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.