Opened 12 years ago

Closed 12 years ago

#9442 closed (duplicate)

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
Component: File uploads/storage Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: 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.

The solution:
Replacing normcase() with normpath() gives all the usual benefits of normcase() but without the case conversion

More Motivation:
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.

My recommendation:
Replace normcase() with normpath() in

Change History (1)

comment:1 Changed 12 years ago by Karen Tracey

Resolution: duplicate
Status: newclosed

#8593 already reports this.

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