#19046: staticfiles not finding the files on Windows
-------------------------------------+--------------------
Reporter: nelutzu_13@… | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.staticfiles | Version: 1.4
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+--------------------
I'm using Django 1.4 on Windows XP and when a file is requested from
STATIC_ROOT I get the following error:
{{{
Traceback (most recent call last):
File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "C:\Python27\lib\site-
packages\django\contrib\staticfiles\handlers.py", line 68, in __call__
return super(StaticFilesHandler, self).__call__(environ,
start_response)
File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line
241, in __call__
response = self.get_response(request)
File "C:\Python27\lib\site-
packages\django\contrib\staticfiles\handlers.py", line 58, in get_response
return self.serve(request)
File "C:\Python27\lib\site-
packages\django\contrib\staticfiles\handlers.py", line 51, in serve
return serve(request, self.file_path(request.path), insecure=True)
File "C:\Python27\lib\site-
packages\django\contrib\staticfiles\views.py", line 35, in serve
absolute_path = finders.find(normalized_path)
File "C:\Python27\lib\site-
packages\django\contrib\staticfiles\finders.py", line 238, in find
result = finder.find(path, all=all)
File "C:\Python27\lib\site-
packages\django\contrib\staticfiles\finders.py", line 78, in find
matched_path = self.find_location(root, path, prefix)
File "C:\Python27\lib\site-
packages\django\contrib\staticfiles\finders.py", line 95, in find_location
path = safe_join(root, path)
File "C:\Python27\lib\site-packages\django\utils\_os.py", line 52, in
safe_join
'path component (%s)' % (final_path, base_path))
ValueError: The joined path (C:\images\common\fnurse.jpg) is located
outside of the base path component (C:\DJANGO\webtech-proto-work\static)
[01/Oct/2012 09:34:06] "GET /static/images/common/fnurse.jpg HTTP/1.1" 500
59
}}}
I have traced the cause of the error to line 37 in staticfiles/views.py :
{{{
normalized_path = posixpath.normpath(unquote(path)).lstrip('/')
}}}
I have replaced the hardcoded '/' to os.sep and after that static files
have been served on Windows. Please check if this change is correct and if
it correct than please integrate it.
--
Ticket URL: <https://code.djangoproject.com/ticket/19046>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.