Merge pull request #265940 from microsoft/anthonykim1/openUrlWithPermission

Fix links opening regardless of confirm of "Opening URIs can be insecure" warning.
This commit is contained in:
Daniel Imms
2025-09-12 04:01:55 -07:00
committed by GitHub
@@ -105,7 +105,7 @@ export class TerminalLinkManager extends DisposableStore {
}));
this._xterm.options.linkHandler = {
allowNonHttpProtocols: true,
activate: (event, text) => {
activate: async (event, text) => {
if (!this._isLinkActivationModifierDown(event)) {
return;
}
@@ -115,18 +115,27 @@ export class TerminalLinkManager extends DisposableStore {
}
const scheme = text.substring(0, colonIndex);
if (terminalConfigurationService.config.allowedLinkSchemes.indexOf(scheme) === -1) {
notificationService.prompt(Severity.Warning, nls.localize('scheme', 'Opening URIs can be insecure, do you want to allow opening links with the scheme {0}?', scheme), [
{
label: nls.localize('allow', 'Allow {0}', scheme),
run: () => {
const allowedLinkSchemes = [
...terminalConfigurationService.config.allowedLinkSchemes,
scheme
];
this._configurationService.updateValue(`terminal.integrated.allowedLinkSchemes`, allowedLinkSchemes);
const userAllowed = await new Promise<boolean>((resolve) => {
notificationService.prompt(Severity.Warning, nls.localize('scheme', 'Opening URIs can be insecure, do you want to allow opening links with the scheme {0}?', scheme), [
{
label: nls.localize('allow', 'Allow {0}', scheme),
run: () => {
const allowedLinkSchemes = [
...terminalConfigurationService.config.allowedLinkSchemes,
scheme
];
this._configurationService.updateValue(`terminal.integrated.allowedLinkSchemes`, allowedLinkSchemes);
resolve(true);
}
}
}
]);
], {
onCancel: () => resolve(false)
});
});
if (!userAllowed) {
return;
}
}
this._openers.get(TerminalBuiltinLinkType.Url)?.open({
type: TerminalBuiltinLinkType.Url,