mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Git protocol handler improvements (#162144)
This commit is contained in:
parent
8044546365
commit
7559012a34
|
@ -12,6 +12,7 @@ import * as querystring from 'querystring';
|
|||
import { OutputChannelLogger } from './log';
|
||||
|
||||
const schemes = new Set(['file', 'git', 'http', 'https', 'ssh']);
|
||||
const refRegEx = /^$|[~\^:\\\*\s\[\]]|^-|^\.|\/\.|\.\.|\.lock\/|\.lock$|\/$|\.$/;
|
||||
|
||||
export class GitProtocolHandler implements UriHandler {
|
||||
|
||||
|
@ -44,7 +45,7 @@ export class GitProtocolHandler implements UriHandler {
|
|||
}
|
||||
|
||||
if (ref !== undefined && typeof ref !== 'string') {
|
||||
this.outputChannelLogger.logWarning('Failed to open URI:' + uri.toString());
|
||||
this.outputChannelLogger.logWarning('Failed to open URI due to multiple references:' + uri.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -62,6 +63,11 @@ export class GitProtocolHandler implements UriHandler {
|
|||
if (!schemes.has(cloneUri.scheme.toLowerCase())) {
|
||||
throw new Error('Unsupported scheme.');
|
||||
}
|
||||
|
||||
// Validate the reference
|
||||
if (typeof ref === 'string' && refRegEx.test(ref)) {
|
||||
throw new Error('Invalid reference.');
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
this.outputChannelLogger.logWarning('Invalid URI:' + uri.toString());
|
||||
|
|
Loading…
Reference in a new issue