OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of dart._vmservice; | 5 part of dart._vmservice; |
6 | 6 |
7 String _encodeDevFSDisabledError(Message message) { | 7 String _encodeDevFSDisabledError(Message message) { |
8 return encodeRpcError( | 8 return encodeRpcError( |
9 message, kFeatureDisabled, | 9 message, kFeatureDisabled, |
10 details: "DevFS is not supported by this Dart implementation"); | 10 details: "DevFS is not supported by this Dart implementation"); |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 Uri resolvePath(String path) { | 31 Uri resolvePath(String path) { |
32 if (path.startsWith('/')) { | 32 if (path.startsWith('/')) { |
33 path = path.substring(1); | 33 path = path.substring(1); |
34 } | 34 } |
35 if (path.isEmpty) { | 35 if (path.isEmpty) { |
36 return null; | 36 return null; |
37 } | 37 } |
38 Uri pathUri; | 38 Uri pathUri; |
39 try { | 39 try { |
40 pathUri = Uri.parse(path); | 40 pathUri = new Uri.file(path); |
41 } on FormatException catch(e) { | 41 } on FormatException catch(e) { |
42 return null; | 42 return null; |
43 } | 43 } |
| 44 |
| 45 try { |
| 46 // Make sure that this pathUri can be converted to a file path. |
| 47 pathUri.toFilePath(); |
| 48 } on UnsupportedError catch (e) { |
| 49 return null; |
| 50 } |
| 51 |
44 Uri resolvedUri = uri.resolveUri(pathUri); | 52 Uri resolvedUri = uri.resolveUri(pathUri); |
45 if (!resolvedUri.toString().startsWith(uri.toString())) { | 53 if (!resolvedUri.toString().startsWith(uri.toString())) { |
46 // Resolved uri must be within the filesystem's base uri. | 54 // Resolved uri must be within the filesystem's base uri. |
47 return null; | 55 return null; |
48 } | 56 } |
49 return resolvedUri; | 57 return resolvedUri; |
50 } | 58 } |
51 | 59 |
52 Map toMap() { | 60 Map toMap() { |
53 return { | 61 return { |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 return encodeMissingParamError(message, 'fsName'); | 314 return encodeMissingParamError(message, 'fsName'); |
307 } | 315 } |
308 if (fsName is! String) { | 316 if (fsName is! String) { |
309 return encodeInvalidParamError(message, 'fsName'); | 317 return encodeInvalidParamError(message, 'fsName'); |
310 } | 318 } |
311 var fs = _fsMap[fsName]; | 319 var fs = _fsMap[fsName]; |
312 if (fs == null) { | 320 if (fs == null) { |
313 return _encodeFileSystemDoesNotExistError(message, fsName); | 321 return _encodeFileSystemDoesNotExistError(message, fsName); |
314 } | 322 } |
315 var fileList = await listFiles(fs.uri); | 323 var fileList = await listFiles(fs.uri); |
| 324 // Remove any url-encoding in the filenames. |
| 325 for (int i = 0; i < fileList.length; i++) { |
| 326 fileList[i]['name'] = Uri.decodeFull(fileList[i]['name']); |
| 327 } |
316 var result = { 'type': 'FSFileList', 'files': fileList }; | 328 var result = { 'type': 'FSFileList', 'files': fileList }; |
317 return encodeResult(message, result); | 329 return encodeResult(message, result); |
318 } | 330 } |
319 } | 331 } |
OLD | NEW |