@@ -169,7 +169,7 @@ export interface Client {
169169activeDocumentChanged ( document :vscode . TextDocument ) :void ;
170170activate ( ) :void ;
171171selectionChanged ( selection :vscode . Position ) :void ;
172- sendCustomConfigurations ( configs :SourceFileConfigurationItem [ ] ) :void ;
172+ sendCustomConfigurations ( configs :any ) :void ;
173173resetDatabase ( ) :void ;
174174deactivate ( ) :void ;
175175pauseParsing ( ) :void ;
@@ -997,9 +997,27 @@ class DefaultClient implements Client {
997997this . notifyWhenReady ( ( ) => this . languageClient . sendNotification ( ChangeCompileCommandsNotification , params ) ) ;
998998}
999999
1000- public sendCustomConfigurations ( configs :SourceFileConfigurationItem [ ] ) :void {
1000+ public sendCustomConfigurations ( configs :any ) :void {
1001+ // 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.
1002+ if ( ! configs || ! ( configs instanceof Array ) ) {
1003+ return ;
1004+ }
1005+ let sanitized :SourceFileConfigurationItem [ ] = < SourceFileConfigurationItem [ ] > configs ;
1006+ sanitized = sanitized . filter ( item => {
1007+ if ( item && item . uri && item . configuration &&
1008+ item . configuration . includePath && item . configuration . defines && item . configuration . intelliSenseMode && item . configuration . standard ) {
1009+ return true ;
1010+ }
1011+ console . warn ( "discarding invalid SourceFileConfigurationItem: " + item ) ;
1012+ return false ;
1013+ } ) ;
1014+
1015+ if ( sanitized . length === 0 ) {
1016+ return ;
1017+ }
1018+
10011019let params :CustomConfigurationParams = {
1002- configurationItems :configs
1020+ configurationItems :sanitized
10031021} ;
10041022this . notifyWhenReady ( ( ) => this . languageClient . sendNotification ( CustomConfigurationNotification , params ) ) ;
10051023}
@@ -1104,7 +1122,7 @@ class NullClient implements Client {
11041122queueTaskWithTimeout ( task :( ) => Thenable < any > , ms :number , tokenSource ?:CancellationTokenSource ) :Thenable < any > { return task ( ) ; }
11051123requestWhenReady ( request :( ) => Thenable < any > ) :Thenable < any > { return ; }
11061124notifyWhenReady ( notify :( ) => void ) :void { }
1107- sendCustomConfigurations ( configs :SourceFileConfigurationItem [ ] ) :void { }
1125+ sendCustomConfigurations ( configs :any ) :void { }
11081126requestGoToDeclaration ( ) :Thenable < void > { return Promise . resolve ( ) ; }
11091127requestSwitchHeaderSource ( rootPath :string , fileName :string ) :Thenable < string > { return Promise . resolve ( "" ) ; }
11101128requestNavigationList ( document :vscode . TextDocument ) :Thenable < string > { return Promise . resolve ( "" ) ; }