@@ -1702,7 +1702,7 @@ export class DefaultClient implements Client {
17021702return this . callTaskWithTimeout ( provideConfigurationAsync , configProviderTimeout , tokenSource ) . then (
17031703( configs ?:SourceFileConfigurationItem [ ] | null ) => {
17041704if ( configs && configs . length > 0 ) {
1705- this . sendCustomConfigurations ( configs ) ;
1705+ this . sendCustomConfigurations ( configs , provider . version ) ;
17061706}
17071707onFinished ( ) ;
17081708} ,
@@ -2364,19 +2364,24 @@ export class DefaultClient implements Client {
23642364this . notifyWhenReady ( ( ) => this . languageClient . sendNotification ( ChangeCompileCommandsNotification , params ) ) ;
23652365}
23662366
2367- private isSourceFileConfigurationItem ( input :any ) :input isSourceFileConfigurationItem {
2367+ private isSourceFileConfigurationItem ( input :any , providerVersion :Version ) :input isSourceFileConfigurationItem {
2368+ // IntelliSenseMode and standard are optional for version 5+. However, they are required when compilerPath is not defined.
2369+ let areOptionalsValid :boolean = false ;
2370+ if ( providerVersion < Version . v5 || input . configuration . compilerPath === undefined ) {
2371+ areOptionalsValid = util . isString ( input . configuration . intelliSenseMode ) && util . isString ( input . configuration . standard ) ;
2372+ } else if ( util . isString ( input . configuration . compilerPath ) ) {
2373+ areOptionalsValid = util . isOptionalString ( input . configuration . intelliSenseMode ) && util . isOptionalString ( input . configuration . standard ) ;
2374+ }
23682375return ( input && ( util . isString ( input . uri ) || util . isUri ( input . uri ) ) &&
23692376input . configuration &&
2377+ areOptionalsValid &&
23702378util . isArrayOfString ( input . configuration . includePath ) &&
23712379util . isArrayOfString ( input . configuration . defines ) &&
2372- util . isString ( input . configuration . intelliSenseMode ) &&
2373- util . isString ( input . configuration . standard ) &&
2374- util . isOptionalString ( input . configuration . compilerPath ) &&
23752380util . isOptionalArrayOfString ( input . configuration . compilerArgs ) &&
23762381util . isOptionalArrayOfString ( input . configuration . forcedInclude ) ) ;
23772382}
23782383
2379- private sendCustomConfigurations ( configs :any ) :void {
2384+ private sendCustomConfigurations ( configs :any , providerVersion : Version ) :void {
23802385// configs is marked as 'any' because it is untrusted data coming from a 3rd-party. We need to sanitize it before sending it to the language server.
23812386if ( ! configs || ! ( configs instanceof Array ) ) {
23822387console . warn ( "discarding invalid SourceFileConfigurationItems[]: " + configs ) ;
@@ -2390,7 +2395,7 @@ export class DefaultClient implements Client {
23902395}
23912396const sanitized :SourceFileConfigurationItemAdapter [ ] = [ ] ;
23922397configs . forEach ( item => {
2393- if ( this . isSourceFileConfigurationItem ( item ) ) {
2398+ if ( this . isSourceFileConfigurationItem ( item , providerVersion ) ) {
23942399this . configurationLogging . set ( item . uri . toString ( ) , JSON . stringify ( item . configuration , null , 4 ) ) ;
23952400if ( settings . loggingLevel === "Debug" ) {
23962401out . appendLine ( ` uri:${ item . uri . toString ( ) } ` ) ;
@@ -2432,6 +2437,15 @@ export class DefaultClient implements Client {
24322437private browseConfigurationLogging :string = "" ;
24332438private configurationLogging :Map < string , string > = new Map < string , string > ( ) ;
24342439
2440+ private isWorkspaceBrowseConfiguration ( input :any ) :boolean {
2441+ const areOptionalsValid :boolean = ( input . compilerPath === undefined && util . isString ( input . standard ) ) ||
2442+ ( util . isString ( input . compilerPath ) && util . isOptionalString ( input . standard ) ) ;
2443+ return areOptionalsValid &&
2444+ util . isArrayOfString ( input . browsePath ) &&
2445+ util . isOptionalString ( input . compilerArgs ) &&
2446+ util . isOptionalString ( input . windowsSdkVersion ) ;
2447+ }
2448+
24352449private sendCustomBrowseConfiguration ( config :any , providerId ?:string , timeoutOccured ?:boolean ) :void {
24362450const rootFolder :vscode . WorkspaceFolder | undefined = this . RootFolder ;
24372451if ( ! rootFolder ) {
@@ -2461,11 +2475,7 @@ export class DefaultClient implements Client {
24612475}
24622476
24632477sanitized = { ...< WorkspaceBrowseConfiguration > config } ;
2464- if ( ! util . isArrayOfString ( sanitized . browsePath ) ||
2465- ! util . isOptionalString ( sanitized . compilerPath ) ||
2466- ! util . isOptionalArrayOfString ( sanitized . compilerArgs ) ||
2467- ! util . isOptionalString ( sanitized . standard ) ||
2468- ! util . isOptionalString ( sanitized . windowsSdkVersion ) ) {
2478+ if ( ! this . isWorkspaceBrowseConfiguration ( sanitized ) ) {
24692479console . log ( "Received an invalid browse configuration from configuration provider." ) ;
24702480const configValue :WorkspaceBrowseConfiguration | undefined = lastCustomBrowseConfiguration . Value ;
24712481if ( configValue ) {