Ejemplo 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 ""
Ejemplo 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")
Ejemplo n.º 3
0
 def test_with_dot(self):
     path = s3boto.safe_join("", "path/./somewhere/../other", "..",
                             ".", "to/./somewhere")
     self.assertEquals(path, "path/to/somewhere")
Ejemplo 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")
Ejemplo 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/")
Ejemplo 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")
Ejemplo n.º 7
0
 def test_with_dot(self):
     path = s3boto.safe_join("", "path/./somewhere/../other", "..", ".",
                             "to/./somewhere")
     self.assertEquals(path, "path/to/somewhere")
Ejemplo 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")
Ejemplo 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/")
Ejemplo 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")
Ejemplo 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")