Skip to content

Commit 0c8a6d5

Browse files
committed
Addresses concerns in microsoft#19624
1 parent d4a9c30 commit 0c8a6d5

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

extensions/php/package.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,22 @@
9494
"fileMatch": "composer.json",
9595
"url": "https://getcomposer.org/schema.json"
9696
}
97-
]
97+
],
98+
"commands": [
99+
{
100+
"title": "%command.untrustValidationExecutable%",
101+
"category": "%commands.categroy.php%",
102+
"command": "php.untrustValidationExecutable"
103+
}
104+
],
105+
"menus": {
106+
"commandPalette": [
107+
{
108+
"command": "php.untrustValidationExecutable",
109+
"when": "php.untrustValidationExecutableContext"
110+
}
111+
]
112+
}
98113
},
99114
"scripts": {
100115
"compile": "gulp compile-extension:php",

extensions/php/package.nls.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
"configuration.validate.enable": "Enable/disable built-in PHP validation.",
44
"configuration.validate.executablePath": "Points to the PHP executable.",
55
"configuration.validate.run": "Whether the linter is run on save or on type.",
6-
"configuration.title": "PHP"
6+
"configuration.title": "PHP",
7+
"commands.categroy.php": "PHP",
8+
"command.untrustValidationExecutable": "Don't trust PHP validation executable"
79
}

extensions/php/src/features/validationProvider.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export default class PHPValidationProvider {
115115
this.diagnosticCollection.delete(textDocument.uri);
116116
delete this.delayers[textDocument.uri.toString()];
117117
}, null, subscriptions);
118+
subscriptions.push(vscode.commands.registerCommand('php.untrustValidationExecutable', this.untrustValidationExecutable, this));
118119
}
119120

120121
public dispose(): void {
@@ -140,6 +141,9 @@ export default class PHPValidationProvider {
140141
}
141142
this.trigger = RunTrigger.from(section.get<string>('validate.run', RunTrigger.strings.onSave));
142143
}
144+
if (this.executableIsUserDefined !== true && this.workspaceStore.get<string>(CheckedExecutablePath, undefined) !== void 0) {
145+
vscode.commands.executeCommand('setContext', 'php.untrustValidationExecutableContext', true);
146+
}
143147
this.delayers = Object.create(null);
144148
if (this.pauseValidation) {
145149
this.pauseValidation = oldExecutable === this.executable;
@@ -161,6 +165,11 @@ export default class PHPValidationProvider {
161165
}
162166
}
163167

168+
private untrustValidationExecutable() {
169+
this.workspaceStore.update(CheckedExecutablePath, undefined);
170+
vscode.commands.executeCommand('setContext', 'php.untrustValidationExecutableContext', false);
171+
}
172+
164173
private triggerValidate(textDocument: vscode.TextDocument): void {
165174
if (textDocument.languageId !== 'php' || this.pauseValidation || !this.validationEnabled) {
166175
return;
@@ -193,19 +202,14 @@ export default class PHPValidationProvider {
193202
title: localize('php.no', 'No'),
194203
isCloseAffordance: true,
195204
id: 'no'
196-
},
197-
{
198-
title: localize('php.more', 'Learn More'),
199-
id: 'more'
200205
}
201206
).then(selected => {
202207
if (!selected || selected.id === 'no') {
203208
this.pauseValidation = true;
204209
} else if (selected.id === 'yes') {
205210
this.workspaceStore.update(CheckedExecutablePath, this.executable);
211+
vscode.commands.executeCommand('setContext', 'php.untrustValidationExecutableContext', true);
206212
trigger();
207-
} else if (selected.id === 'more') {
208-
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://go.microsoft.com/fwlink/?linkid=839878'));
209213
}
210214
});
211215
return;

0 commit comments

Comments
 (0)