Index: sdk/lib/_internal/pub/lib/src/package.dart |
diff --git a/sdk/lib/_internal/pub/lib/src/package.dart b/sdk/lib/_internal/pub/lib/src/package.dart |
index 29c9b1fadc4686bbad71826ac0134bbe11045728..211eb37e6a1de862d7c030b152014e9af64bcc37 100644 |
--- a/sdk/lib/_internal/pub/lib/src/package.dart |
+++ b/sdk/lib/_internal/pub/lib/src/package.dart |
@@ -172,6 +172,17 @@ class Package { |
} |
return files.where((file) { |
+ // 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(file.startsWith(beneath)); |
file = file.substring(beneath.length); |
return !_blacklistedFiles.any(file.endsWith) && |
!_blacklistedDirs.any(file.contains); |