1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 import os
19
20 from flumotion.component.misc.httpserver import fileprovider
21 from flumotion.component.misc.httpserver import ourmimetypes
22 from flumotion.component.misc.httpserver.fileprovider import InsecureError
23 from flumotion.component.misc.httpserver.fileprovider import NotFoundError
24
25
28
29
31
32 contentTypes = ourmimetypes.MimeTypes()
33
34
35 mimeType = None
36
40
43
47
49 raise NotImplementedError()
50
51
52
53
55 """
56 @param name: the name of a child of the pointed directory
57 @type name: str
58
59 @return: the path of the child
60 @rtype: str
61 @raises InsecureError: if the specified name compromise security
62 """
63 norm = os.path.normpath(name)
64 if os.sep in norm:
65 raise InsecureError("Child name '%s' contains one or more "
66 "directory separators" % (name, ))
67 childpath = os.path.abspath(os.path.join(self._path, norm))
68 if not childpath.startswith(self._path):
69 raise InsecureError("Path '%s' is not a child of '%s'"
70 % (childpath, self._path))
71 return childpath
72