﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
19046	staticfiles not finding the files on Windows	nelutzu_13@…	nobody	"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.

"	Bug	closed	contrib.staticfiles	1.4	Normal	needsinfo			Accepted	0	0	0	0	0	0
