Skip to content

Commit e8348ac

Browse files
committed
Check format of URI
1 parent 5efc383 commit e8348ac

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

extensions/ql-vscode/src/pure/bqrs-utils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,18 @@ export function tryGetRemoteLocation(
111111
// "file:${sourceLocationPrefix}/relative/path/to/file"
112112
// So we need to strip off the first part to get the relative path.
113113
if (sourceLocationPrefix) {
114+
if (!resolvableLocation.uri.startsWith(`file:${sourceLocationPrefix}/`)) {
115+
return undefined;
116+
}
114117
trimmedLocation = resolvableLocation.uri.replace(`file:${sourceLocationPrefix}/`, '');
115118
} else {
116119
// If the source location prefix is empty (e.g. for older remote queries), we assume that the database
117120
// was created on a Linux actions runner and has the format:
118-
// "file:/home/runner/work/<repo>/<repo/relative/path/to/file"
121+
// "file:/home/runner/work/<repo>/<repo>/relative/path/to/file"
119122
// So we need to drop the first 6 parts of the path.
123+
if (!resolvableLocation.uri.startsWith('file:/home/runner/work/')) {
124+
return undefined;
125+
}
120126
const locationParts = resolvableLocation.uri.split('/');
121127
trimmedLocation = locationParts.slice(6, locationParts.length).join('/');
122128
}

0 commit comments

Comments
 (0)