Skip to content

Commit cb29362

Browse files
committed
1 parent 18cb88e commit cb29362

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

extensions/extension-editing/src/extensionLinter.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ import { languages, workspace, Disposable, TextDocument, Uri, Diagnostic, Range,
1616

1717
const product = JSON.parse(fs.readFileSync(path.join(env.appRoot, 'product.json'), { encoding: 'utf-8' }));
1818
const allowedBadgeProviders: string[] = (product.extensionAllowedBadgeProviders || []).map((s: string) => s.toLowerCase());
19+
const allowedBadgeProvidersRegex: RegExp[] = (product.extensionAllowedBadgeProvidersRegex || []).map((r: string) => new RegExp(r));
20+
21+
function isTrustedSVGSource(uri: Uri): boolean {
22+
return allowedBadgeProviders.includes(uri.authority.toLowerCase()) || allowedBadgeProvidersRegex.some(r => r.test(uri.toString()));
23+
}
1924

2025
const httpsRequired = localize('httpsRequired', "Images must use the HTTPS protocol.");
2126
const svgsNotValid = localize('svgsNotValid', "SVGs are not a valid image source.");
@@ -321,7 +326,7 @@ export class ExtensionLinter {
321326
diagnostics.push(new Diagnostic(range, message, DiagnosticSeverity.Warning));
322327
}
323328

324-
if (endsWith(uri.path.toLowerCase(), '.svg') && allowedBadgeProviders.indexOf(uri.authority.toLowerCase()) === -1) {
329+
if (endsWith(uri.path.toLowerCase(), '.svg') && !isTrustedSVGSource(uri)) {
325330
const range = new Range(document.positionAt(begin), document.positionAt(end));
326331
diagnostics.push(new Diagnostic(range, svgsNotValid, DiagnosticSeverity.Warning));
327332
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "code-oss-dev",
33
"version": "1.47.0",
4-
"distro": "4eca5644666fe6fde9d765e71d0ca870f3c076a6",
4+
"distro": "6ddb25a97095c2b3a88c3e54cbf7c4657c5bdf4d",
55
"author": {
66
"name": "Microsoft Corporation"
77
},
@@ -181,4 +181,4 @@
181181
"windows-mutex": "0.3.0",
182182
"windows-process-tree": "0.2.4"
183183
}
184-
}
184+
}

0 commit comments

Comments
 (0)