mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user