Esempio n. 1
0
    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 ""
Esempio n. 2
0
 def test_base_url_with_slash(self):
     path = s3boto.safe_join("base_url/", "path/to/somewhere")
     self.assertEquals(path, "base_url/path/to/somewhere")
Esempio n. 3
0
 def test_with_dot(self):
     path = s3boto.safe_join("", "path/./somewhere/../other", "..",
                             ".", "to/./somewhere")
     self.assertEquals(path, "path/to/somewhere")
Esempio n. 4
0
 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")
Esempio n. 5
0
 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/")
Esempio n. 6
0
 def test_base_url(self):
     path = s3boto.safe_join("base_url", "path/to/somewhere")
     self.assertEquals(path, "base_url/path/to/somewhere")
Esempio n. 7
0
 def test_with_dot(self):
     path = s3boto.safe_join("", "path/./somewhere/../other", "..", ".",
                             "to/./somewhere")
     self.assertEquals(path, "path/to/somewhere")
Esempio n. 8
0
 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")
Esempio n. 9
0
 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/")
Esempio n. 10
0
 def test_base_url(self):
     path = s3boto.safe_join("base_url", "path/to/somewhere")
     self.assertEqual(path, "base_url/path/to/somewhere")
Esempio n. 11
0
 def test_base_url_with_slash(self):
     path = s3boto.safe_join("base_url/", "path/to/somewhere")
     self.assertEqual(path, "base_url/path/to/somewhere")