Skip to content

Commit 2f65beb

Browse files
committed
Sanitize cache keys for symbol index
Signed-off-by: BoykoAlex <alex.boyko@broadcom.com>
1 parent 0269b6b commit 2f65beb

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

  • headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/index/cache

headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/index/cache/IndexCacheKey.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,17 @@ public class IndexCacheKey {
2525
private final String version;
2626

2727
public IndexCacheKey(String project, String indexer, String category, String version) {
28-
this.project = project;
29-
this.indexer = indexer;
30-
this.category = category;
31-
this.version = version;
28+
this.project = requireNoPathSeparator(project, "project");
29+
this.indexer = requireNoPathSeparator(indexer, "indexer");
30+
this.category = requireNoPathSeparator(category, "category");
31+
this.version = requireNoPathSeparator(version, "version");
32+
}
33+
34+
private static String requireNoPathSeparator(String value, String fieldName) {
35+
if (value != null && (value.indexOf('/') >= 0 || value.indexOf('\\') >= 0)) {
36+
throw new IllegalArgumentException("Invalid " + fieldName + " for index cache key, must not contain a path separator: " + value);
37+
}
38+
return value;
3239
}
3340

3441
public String getProject() {

0 commit comments

Comments
 (0)