##// END OF EJS Templates
s/os.path.sep/os.sep/
MinRK -
Show More
@@ -299,7 +299,7 b' class AuthenticatedFileHandler(IPythonHandler, web.StaticFileHandler):'
299 299 or the UF_HIDDEN flag as reported by stat
300 300 """
301 301 inside_root = absolute_path[len(absolute_root):]
302 if any(part.startswith('.') for part in inside_root.split(os.path.sep)):
302 if any(part.startswith('.') for part in inside_root.split(os.sep)):
303 303 raise web.HTTPError(403)
304 304
305 305 # check UF_HIDDEN on any location up to root
@@ -367,7 +367,7 b' class FileFindHandler(web.StaticFileHandler):'
367 367 if isinstance(path, basestring):
368 368 path = [path]
369 369 self.roots = tuple(
370 os.path.abspath(os.path.expanduser(p)) + os.path.sep for p in path
370 os.path.abspath(os.path.expanduser(p)) + os.sep for p in path
371 371 )
372 372 self.default_filename = default_filename
373 373
@@ -385,7 +385,7 b' class FileFindHandler(web.StaticFileHandler):'
385 385
386 386 # os.path.abspath strips a trailing /
387 387 # it needs to be temporarily added back for requests to root/
388 if not (abspath + os.path.sep).startswith(roots):
388 if not (abspath + os.sep).startswith(roots):
389 389 raise HTTPError(403, "%s is not in root static directory", path)
390 390
391 391 cls._static_paths[path] = abspath
@@ -470,7 +470,7 b' class FileFindHandler(web.StaticFileHandler):'
470 470 if isinstance(static_paths, basestring):
471 471 static_paths = [static_paths]
472 472 roots = tuple(
473 os.path.abspath(os.path.expanduser(p)) + os.path.sep for p in static_paths
473 os.path.abspath(os.path.expanduser(p)) + os.sep for p in static_paths
474 474 )
475 475
476 476 try:
@@ -504,8 +504,8 b' class FileFindHandler(web.StaticFileHandler):'
504 504 ``static_url_prefix`` removed. The return value should be
505 505 filesystem path relative to ``static_path``.
506 506 """
507 if os.path.sep != "/":
508 url_path = url_path.replace("/", os.path.sep)
507 if os.sep != "/":
508 url_path = url_path.replace("/", os.sep)
509 509 return url_path
510 510
511 511 class TrailingSlashHandler(web.RequestHandler):
@@ -102,12 +102,12 b' class APITest(NotebookTestBase):'
102 102 nbdir = self.notebook_dir.name
103 103
104 104 for d in self.dirs:
105 d.replace('/', os.path.sep)
105 d.replace('/', os.sep)
106 106 if not os.path.isdir(pjoin(nbdir, d)):
107 107 os.mkdir(pjoin(nbdir, d))
108 108
109 109 for d, name in self.dirs_nbs:
110 d = d.replace('/', os.path.sep)
110 d = d.replace('/', os.sep)
111 111 with io.open(pjoin(nbdir, d, '%s.ipynb' % name), 'w') as f:
112 112 nb = new_notebook(name=name)
113 113 write(nb, f, format='ipynb')
@@ -172,7 +172,7 b' class APITest(NotebookTestBase):'
172 172 self.assertEqual(resp.json()['name'], name)
173 173 assert os.path.isfile(pjoin(
174 174 self.notebook_dir.name,
175 path.replace('/', os.path.sep),
175 path.replace('/', os.sep),
176 176 name,
177 177 ))
178 178
@@ -27,7 +27,7 b' class FilesTest(NotebookTestBase):'
27 27
28 28 nbdir = self.notebook_dir.name
29 29 for d in dirs:
30 path = pjoin(nbdir, d.replace('/', os.path.sep))
30 path = pjoin(nbdir, d.replace('/', os.sep))
31 31 if not os.path.exists(path):
32 32 os.mkdir(path)
33 33 with open(pjoin(path, 'foo'), 'w') as f:
@@ -37,7 +37,7 b' class FilesTest(NotebookTestBase):'
37 37 url = self.base_url()
38 38
39 39 for d in not_hidden:
40 path = pjoin(nbdir, d.replace('/', os.path.sep))
40 path = pjoin(nbdir, d.replace('/', os.sep))
41 41 r = requests.get(url_path_join(url, 'files', d, 'foo'))
42 42 r.raise_for_status()
43 43 self.assertEqual(r.content, b'foo')
@@ -45,7 +45,7 b' class FilesTest(NotebookTestBase):'
45 45 self.assertEqual(r.status_code, 403)
46 46
47 47 for d in hidden:
48 path = pjoin(nbdir, d.replace('/', os.path.sep))
48 path = pjoin(nbdir, d.replace('/', os.sep))
49 49 for foo in ('foo', '.foo'):
50 50 r = requests.get(url_path_join(url, 'files', d, foo))
51 51 self.assertEqual(r.status_code, 403)
@@ -38,7 +38,7 b' def url_path_join(*pieces):'
38 38
39 39 def path2url(path):
40 40 """Convert a local file path to a URL"""
41 pieces = [ quote(p) for p in path.split(os.path.sep) ]
41 pieces = [ quote(p) for p in path.split(os.sep) ]
42 42 # preserve trailing /
43 43 if pieces[-1] == '':
44 44 pieces[-1] = '/'
General Comments 0
You need to be logged in to leave comments. Login now