django/utils/os_py -> safe_join converts file name to lower case when it is a bad idea and this causes incompatibilities with windows / linux
|Reported by:||dawidjoubert||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The function safe_join() is called throughout the django code base to safely join a base path with other paths inbetween and returns a normalised absolute version of the final path.
It calls an underlying function normcase() to normalise the path wich converts the case of the path to all lower case where Python is run in a windows environment. This works all happy chappy where the underlying file system is case insensitive but causes havoc where the underlying file system is actually a mapped network drive.
Replacing normcase() with normpath() gives all the usual benefits of normcase() but without the case conversion
Quite frankly it is a horrible horrible idea for the name under which the field is saved in the database to differ from the name under which it is saved on hard disk. Even on an all Windows setup there could be major headaches where infrastructure want to perhaps move static files onto their own server and decide to use linux to do so.
Plainly put: If the file name is saved as 'uploads/CIMG1335.jpg' in the database then the file name on the hard drive must be exactly uploads/CIMG1335.jpg with the only exception possibly being made that the brackets can be convert to '
' when working on the Windows platform.
Replace normcase() with normpath() in django.utils._os.py