Chromium Code Reviews| Index: pkg/http_server/lib/src/virtual_directory.dart |
| diff --git a/pkg/http_server/lib/src/virtual_directory.dart b/pkg/http_server/lib/src/virtual_directory.dart |
| index bb3b7ac44260916aae1e135a5e7a027441814651..a06a8d57dc713b5da3b25d5d9a5f960f30e9f803 100644 |
| --- a/pkg/http_server/lib/src/virtual_directory.dart |
| +++ b/pkg/http_server/lib/src/virtual_directory.dart |
| @@ -75,13 +75,7 @@ class _VirtualDirectory implements VirtualDirectory { |
| } |
| void serveRequest(HttpRequest request) { |
| - var path = new Path(request.uri.path).canonicalize(); |
| - |
| - if (!path.isAbsolute) { |
| - return _serveErrorPage(HttpStatus.NOT_FOUND, request); |
| - } |
| - |
| - _locateResource(new Path('.'), path.segments()) |
| + _locateResource(new Path('.'), request.uri.pathSegments) |
| .then((entity) { |
| if (entity == null) { |
| _serveErrorPage(HttpStatus.NOT_FOUND, request); |
| @@ -107,6 +101,8 @@ class _VirtualDirectory implements VirtualDirectory { |
| Future<FileSystemEntity> _locateResource(Path path, |
| Iterable<String> segments) { |
| + path = path.canonicalize(); |
|
Lasse Reichstein Nielsen
2013/07/02 07:31:14
So you canonicalize after each segment is added.
W
Anders Johnsen
2013/07/02 11:08:07
Yes, that's the idea.
|
| + if (path.segments().first == "..") return new Future.value(null); |
| Path fullPath() => new Path(root).join(path); |
| return FileSystemEntity.type(fullPath().toNativePath(), followLinks: false) |
| .then((type) { |
| @@ -132,15 +128,8 @@ class _VirtualDirectory implements VirtualDirectory { |
| .then((target) { |
| var targetPath = new Path(target).canonicalize(); |
| if (targetPath.isAbsolute) return null; |
| - targetPath = |
| - path.directoryPath.join(targetPath).canonicalize(); |
| - if (targetPath.segments().isEmpty || |
| - targetPath.segments().first == '..') return null; |
| - if (segments.isEmpty) { |
| - return _locateResource(targetPath, []); |
| - } |
| - return _locateResource(targetPath.append(segments.first), |
| - segments.skip(1)); |
| + targetPath = path.directoryPath.join(targetPath); |
| + return _locateResource(targetPath, segments); |
| }); |
| } |
| break; |