Index: sdk/lib/_internal/pub/lib/src/io.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/io.dart b/sdk/lib/_internal/pub/lib/src/io.dart |
index ffbf30e71dcf45da820faa72b097839f38d69773..7f8c9ec088523d54586b963e7da172130c15ab0b 100644 |
--- a/sdk/lib/_internal/pub/lib/src/io.dart |
+++ b/sdk/lib/_internal/pub/lib/src/io.dart |
@@ -289,6 +289,16 @@ List<String> listDir(String dir, {bool recursive: false, |
if (entity is Link) return false; |
if (includeHidden) return true; |
+ // Using substring here is generally problematic in cases where dir has one |
+ // or more trailing slashes. If you do listDir("foo"), you'll get back |
+ // paths like "foo/bar". If you do listDir("foo/"), you'll get "foo/bar" |
+ // (note the trailing slash was dropped. If you do listDir("foo//"), you'll |
+ // get "foo//bar". |
+ // |
+ // This means if you strip off the prefix, the resulting string may have a |
+ // leading separator (if the prefix did not have a trailing one) or it may |
+ // not. However, since we are only using the results of that to call |
+ // contains() on, the leading separator is harmless. |
assert(entity.path.startsWith(dir)); |
var pathInDir = entity.path.substring(dir.length); |