Index: pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.dart |
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.dart |
index 13282c2fdb2eef21b13aeb648d1dd02fdafe0d06..7e849b148930d4f3aad760b920dfeb42e0ea6f71 100644 |
--- a/pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.dart |
+++ b/pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.dart |
@@ -116,10 +116,16 @@ class _UriSuggestionBuilder extends SimpleAstVisitor { |
if (resContext.isRelative(dirPath)) { |
String sourceDirPath = resContext.dirname(source.fullName); |
if (resContext.isAbsolute(sourceDirPath)) { |
- dirPath = resContext.join(sourceDirPath, dirPath); |
+ dirPath = resContext.normalize(resContext.join(sourceDirPath, dirPath)); |
} else { |
return; |
} |
+ // Do not suggest relative paths reaching outside the 'lib' directory. |
+ bool srcInLib = resContext.split(sourceDirPath).contains('lib'); |
+ bool dstInLib = resContext.split(dirPath).contains('lib'); |
+ if (srcInLib && !dstInLib) { |
+ return; |
+ } |
} |
if (dirPath.endsWith('\\.')) { |
dirPath = dirPath.substring(0, dirPath.length - 1); |