Code

Opened 8 years ago

Closed 6 years ago

#1291 closed defect (fixed)

Django built-in web-server does not handle double-slashes (//) properly, ends up in infinte loop

Reported by: Damian.Jurd@… Owned by: adrian
Component: Generic views Version: master
Severity: major Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Django built-in web-server does not handle double-slashes () properly, ends up in infinte loop

Attachments (1)

static_serve_empty_path_compnent.diff (1.3 KB) - added by graham.carlyle@… 6 years ago.
test to illustrate problem and potential fix

Download all attachments as: .zip

Change History (6)

comment:1 Changed 8 years ago by anonymous

Can you give an example? Everything I've tried results in a 404, as expected.

comment:2 Changed 8 years ago by mattimustang@…

I am seeing this too.

urlpatterns = patterns('',
    (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/path/to/project/media'}),
)

in my template I have something like:

<link rel="stylesheet" type="text/css" href="/site_media//css/site.css" />

which results in the log entry in the builtin django webserver log:

[01/Feb/2006 11:30:33] "GET /site_media//css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/css/site.css HTTP/1.0" 302 0

and the css file doesn't get loaded.

comment:3 Changed 8 years ago by adrian

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

I cannot replicate this on Linux.

comment:4 Changed 6 years ago by graham.carlyle@…

  • Component changed from django-admin.py to Generic views
  • Resolution worksforme deleted
  • Status changed from closed to reopened
  • Version set to SVN

I am able to reproduce the problem. It occurs if the double slash occurs at the start of the path that the regexp captures as the path parameter to the 'django.views.static.serve' function.

So in the example '/site_mediacss/site.css' causes the 'serve' function to respond with a redirection to 'css/site.css' which causes the browser to request '/site_mediacss/css/site.css' and so on... (firefox eventually gives up)

A request of '/site_mediasite.css' causes the 'serve' function to respond with a redirection to 'site.css' which causes the browser to request the same url again (firefox gives up)

So its seems to be a bug in the 'django.views.static.serve' function.

Changed 6 years ago by graham.carlyle@…

test to illustrate problem and potential fix

comment:5 Changed 6 years ago by mtredinnick

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

(In [6731]) Fixed #1291 -- Fixed a potential infinite loop for some URL constructions in
the development server. Thanks, Graham Carlyle.

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.