Skip to content

Commit a671ebe

Browse files
authored
Merge pull request #478 from microsoft/dev/mjbvz/msrc-73975-to-release
Add allow list of valid notebook command uris
2 parents aca9cd9 + 269d6df commit a671ebe

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed

src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -560,24 +560,8 @@ var requirejs = (function() {
560560
return;
561561
}
562562

563-
if (matchesScheme(link, Schemas.command)) {
564-
const ret = /command\:workbench\.action\.openLargeOutput\?(.*)/.exec(link);
565-
if (ret && ret.length === 2) {
566-
const outputId = ret[1];
567-
this.openerService.open(CellUri.generateCellOutputUri(this.documentUri, outputId));
568-
return;
569-
}
570-
console.warn('Command links are deprecated and will be removed, use message passing instead: https://github.com/microsoft/vscode/issues/123601');
571-
}
572-
573-
if (matchesScheme(link, Schemas.command)) {
574-
if (this.workspaceTrustManagementService.isWorkspaceTrusted()) {
575-
this.openerService.open(link, { fromUserGesture: true, allowContributedOpeners: true, allowCommands: true });
576-
} else {
577-
console.warn('Command links are disabled in untrusted workspaces');
578-
}
579-
} else if (matchesSomeScheme(link, Schemas.vscodeNotebookCell, Schemas.http, Schemas.https, Schemas.mailto)) {
580-
this.openerService.open(link, { fromUserGesture: true, allowContributedOpeners: true, allowCommands: true });
563+
if (matchesSomeScheme(link, Schemas.vscodeNotebookCell, Schemas.http, Schemas.https, Schemas.mailto)) {
564+
this.openerService.open(link, { fromUserGesture: true, allowContributedOpeners: true, allowCommands: false });
581565
}
582566
}));
583567

@@ -696,23 +680,35 @@ var requirejs = (function() {
696680
}
697681
case 'clicked-link': {
698682
let linkToOpen: URI | string | undefined;
683+
699684
if (matchesScheme(data.href, Schemas.command)) {
700-
const ret = /command\:workbench\.action\.openLargeOutput\?(.*)/.exec(data.href);
701-
if (ret && ret.length === 2) {
702-
const outputId = ret[1];
703-
const group = this.editorGroupService.activeGroup;
704-
705-
if (group) {
706-
if (group.activeEditor) {
707-
group.pinEditor(group.activeEditor);
685+
// We allow a very limited set of commands
686+
const uri = URI.parse(data.href);
687+
switch (uri.path) {
688+
case 'workbench.action.openLargeOutput': {
689+
const outputId = uri.query;
690+
const group = this.editorGroupService.activeGroup;
691+
if (group) {
692+
if (group.activeEditor) {
693+
group.pinEditor(group.activeEditor);
694+
}
708695
}
709-
}
710696

711-
this.openerService.open(CellUri.generateCellOutputUri(this.documentUri, outputId));
712-
return;
697+
this.openerService.open(CellUri.generateCellOutputUri(this.documentUri, outputId));
698+
return;
699+
}
700+
case 'github-issues.authNow':
701+
case 'workbench.extensions.search':
702+
case 'workbench.extensions.openSettings': {
703+
this.openerService.open(data.href, { fromUserGesture: true, allowCommands: true, fromWorkspace: true });
704+
return;
705+
}
713706
}
707+
708+
return;
714709
}
715-
if (matchesSomeScheme(data.href, Schemas.http, Schemas.https, Schemas.mailto, Schemas.command, Schemas.vscodeNotebookCell, Schemas.vscodeNotebook)) {
710+
711+
if (matchesSomeScheme(data.href, Schemas.http, Schemas.https, Schemas.mailto, Schemas.vscodeNotebookCell, Schemas.vscodeNotebook)) {
716712
linkToOpen = data.href;
717713
} else if (!/^[\w\-]+:/.test(data.href)) {
718714
const fragmentStartIndex = data.href.lastIndexOf('#');
@@ -743,7 +739,7 @@ var requirejs = (function() {
743739
}
744740

745741
if (linkToOpen) {
746-
this.openerService.open(linkToOpen, { fromUserGesture: true, allowCommands: true, fromWorkspace: true });
742+
this.openerService.open(linkToOpen, { fromUserGesture: true, allowCommands: false, fromWorkspace: true });
747743
}
748744
break;
749745
}

0 commit comments

Comments
 (0)