from urlparse import urljoin
base_path = force_unicode(base)
- paths = map(lambda p: force_unicode(p), paths)
- final_path = urljoin(base_path +
- ("/" if not base_path.endswith("/") else ""), *paths)
+ base_path = base_path.rstrip('/')
+ paths = [force_unicode(p) for p in paths]
+ final_path = urljoin(final_path.rstrip('/') + "/", path.rstrip("/"))
# Ensure final_path starts with base_path and that the next character after
# the final path is '/' (or nothing, in which case final_path must be
or final_path[base_path_len:base_path_len + 1] not in ('', '/'):
raise ValueError('the joined path is located outside of the base path'
+ return final_path.lstrip('/')
# Dates returned from S3's API look something like this:
# "Sun, 11 Mar 2012 17:01:41 GMT"
the directory specified by the LOCATION setting.
- return safe_join(self.location, name)
+ return safe_join(self.location, name)
raise SuspiciousOperation("Attempted access to '%s' denied." %