Opened 19 years ago

Closed 17 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 Holovaty
Component: Generic views Version: dev
Severity: major Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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@… 17 years ago.
test to illustrate problem and potential fix

Download all attachments as: .zip

Change History (6)

comment:1 by anonymous, 19 years ago

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

comment:2 by mattimustang@…, 19 years ago

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 by Adrian Holovaty, 19 years ago

Resolution: worksforme
Status: newclosed

I cannot replicate this on Linux.

comment:4 by graham.carlyle@…, 17 years ago

Component: django-admin.pyGeneric views
Resolution: worksforme
Status: closedreopened
Version: 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.

by graham.carlyle@…, 17 years ago

test to illustrate problem and potential fix

comment:5 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: reopenedclosed

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

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