File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed
mcp_nexus_tests/Extensions Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -442,10 +442,21 @@ private string BuildPowerShellParameterArguments(object parameters)
442442 switch ( property . Value . ValueKind )
443443 {
444444 case JsonValueKind . String :
445- // Escape single quotes in string values
446445 var stringValue = property . Value . GetString ( ) ?? string . Empty ;
447- stringValue = stringValue . Replace ( "'" , "''" ) ;
448- argumentsBuilder . Append ( $ " '{ stringValue } '") ;
446+
447+ // Only quote if the value contains spaces or special characters
448+ if ( stringValue . Contains ( ' ' ) || stringValue . Contains ( '"' ) || stringValue . Contains ( '\' ' ) ||
449+ stringValue . Contains ( '$' ) || stringValue . Contains ( '`' ) || string . IsNullOrWhiteSpace ( stringValue ) )
450+ {
451+ // Escape single quotes and wrap in single quotes
452+ stringValue = stringValue . Replace ( "'" , "''" ) ;
453+ argumentsBuilder . Append ( $ " '{ stringValue } '") ;
454+ }
455+ else
456+ {
457+ // Simple value, no quotes needed
458+ argumentsBuilder . Append ( $ " { stringValue } ") ;
459+ }
449460 break ;
450461
451462 case JsonValueKind . Number :
Original file line number Diff line number Diff line change @@ -493,9 +493,12 @@ public async Task ExecuteAsync_WithParameters_PassesParametersAsJson()
493493 new ExtensionTokenValidator ( new LoggerFactory ( ) . CreateLogger < ExtensionTokenValidator > ( ) ) ) ;
494494
495495 var scriptContent = @"
496- $params = $env:MCP_NEXUS_PARAMETERS | ConvertFrom-Json
497- Write-Output ""Param1: $($params.param1)""
498- Write-Output ""Param2: $($params.param2)""
496+ param(
497+ [string]$Param1,
498+ [string]$Param2
499+ )
500+ Write-Output ""Param1: $Param1""
501+ Write-Output ""Param2: $Param2""
499502exit 0
500503" ;
501504 CreateTestScript ( "params.ps1" , scriptContent ) ;
You can’t perform that action at this time.
0 commit comments