def _normalize_name(self, name): """ Normalizes the name so that paths like /path/to/ignored/../something.txt work. We check to make sure that the path pointed to is not outside the directory specified by the LOCATION setting. """ try: return safe_join(self.location, name) except (SuspiciousOperation, ValueError): return ""
def test_base_url_with_slash(self): path = s3boto.safe_join("base_url/", "path/to/somewhere") self.assertEquals(path, "base_url/path/to/somewhere")
def test_with_dot(self): path = s3boto.safe_join("", "path/./somewhere/../other", "..", ".", "to/./somewhere") self.assertEquals(path, "path/to/somewhere")
def test_normal(self): path = s3boto.safe_join("", "path/to/somewhere", "other", "path/to/somewhere") self.assertEquals(path, "path/to/somewhere/other/path/to/somewhere")
def test_trailing_slash_multi(self): """ Test safe_join with multiple paths that end with a trailing slash. """ path = s3boto.safe_join("base_url/", "path/to/" "somewhere/") self.assertEquals(path, "base_url/path/to/somewhere/")
def test_base_url(self): path = s3boto.safe_join("base_url", "path/to/somewhere") self.assertEquals(path, "base_url/path/to/somewhere")
def test_base_url(self): path = s3boto.safe_join("base_url", "path/to/somewhere") self.assertEqual(path, "base_url/path/to/somewhere")
def test_base_url_with_slash(self): path = s3boto.safe_join("base_url/", "path/to/somewhere") self.assertEqual(path, "base_url/path/to/somewhere")