Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: pkg/analysis_server/lib/src/domain_analysis.dart

Issue 1511833004: Validate that root paths are absolute and normalized. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/domain_analysis.dart
diff --git a/pkg/analysis_server/lib/src/domain_analysis.dart b/pkg/analysis_server/lib/src/domain_analysis.dart
index f1bdf14b840600492fd467ec30f3fed5f9b32f6d..bd9d6073a4e1fdbb47b08b8265047cec6c4721e8 100644
--- a/pkg/analysis_server/lib/src/domain_analysis.dart
+++ b/pkg/analysis_server/lib/src/domain_analysis.dart
@@ -175,8 +175,9 @@ class AnalysisDomainHandler implements RequestHandler {
if (pair.context == null || pair.source == null) {
return new Response.getReachableSourcesInvalidFile(request);
}
- Map<String, List<String>> sources = new ReachableSourceCollector(
- pair.source, pair.context).collectSources();
+ Map<String, List<String>> sources =
+ new ReachableSourceCollector(pair.source, pair.context)
+ .collectSources();
return new AnalysisGetReachableSourcesResult(sources)
.toResponse(request.id);
}
@@ -245,9 +246,22 @@ class AnalysisDomainHandler implements RequestHandler {
*/
Response setAnalysisRoots(Request request) {
var params = new AnalysisSetAnalysisRootsParams.fromRequest(request);
+ List<String> includedPathList = params.included;
+ List<String> excludedPathList = params.excluded;
+ // validate
+ for (String path in includedPathList) {
+ if (!server.isValidFilePath(path)) {
+ return new Response.invalidFilePathFormat(request, path);
+ }
+ }
+ for (String path in excludedPathList) {
+ if (!server.isValidFilePath(path)) {
+ return new Response.invalidFilePathFormat(request, path);
+ }
+ }
// continue in server
- server.setAnalysisRoots(request.id, params.included, params.excluded,
- params.packageRoots == null ? {} : params.packageRoots);
+ server.setAnalysisRoots(request.id, includedPathList, excludedPathList,
+ params.packageRoots ?? <String, String>{});
return new AnalysisSetAnalysisRootsResult().toResponse(request.id);
}
@@ -347,8 +361,8 @@ class AnalysisDomainHandler implements RequestHandler {
class AnalysisDomainImpl implements AnalysisDomain {
final AnalysisServer server;
- final Map<ResultDescriptor,
- StreamController<engine.ComputedResult>> controllers =
+ final Map<ResultDescriptor, StreamController<engine.ComputedResult>>
+ controllers =
<ResultDescriptor, StreamController<engine.ComputedResult>>{};
AnalysisDomainImpl(this.server) {

Powered by Google App Engine
This is Rietveld 408576698