@@ -407,23 +407,62 @@ export class CxWrapper {
407
407
return new ExecutionService ( ) . executeCommands ( this . config . pathToExecutable , commands , CxConstants . MASK_TYPE ) ;
408
408
}
409
409
410
- prepareAdditionalParams ( additionalParameters : string ) : string [ ] {
411
- const params : string [ ] = [ ] ;
412
410
411
+ /**
412
+ * Splits additional CLI parameters into an array of tokens,
413
+ * correctly handling quoted values and key=value pairs.
414
+ *
415
+ * @param additionalParameters - A single string containing extra parameters
416
+ * @returns Array of cleaned tokens ready to pass to the CLI
417
+ */
418
+ private prepareAdditionalParams ( additionalParameters : string ) : string [ ] {
413
419
if ( ! additionalParameters ) {
414
- return params ;
415
- }
420
+ return [ ] ;
421
+ }
422
+
423
+ // Trim whitespace and remove surrounding quotes if present
424
+ let trimmed = additionalParameters . trim ( ) ;
425
+ if (
426
+ ( trimmed . startsWith ( '"' ) && trimmed . endsWith ( '"' ) ) ||
427
+ ( trimmed . startsWith ( "'" ) && trimmed . endsWith ( "'" ) )
428
+ ) {
429
+ trimmed = trimmed . slice ( 1 , - 1 ) ;
430
+ }
431
+
432
+ // Regex matches sequences without whitespace or quoted segments
433
+ const regex = / (?: [ ^ \s ' " ] + | ' [ ^ ' ] * ' | " [ ^ " ] * " ) + / g;
434
+ const rawTokens = trimmed . match ( regex ) || [ ] ;
435
+
436
+ // Process tokens: remove quotes and handle key=value syntax
437
+ return rawTokens . map ( token => {
438
+ // Remove surrounding quotes
439
+ if (
440
+ ( token . startsWith ( '"' ) && token . endsWith ( '"' ) ) ||
441
+ ( token . startsWith ( "'" ) && token . endsWith ( "'" ) )
442
+ ) {
443
+ token = token . slice ( 1 , - 1 ) ;
444
+ }
416
445
417
- const paramList = additionalParameters . match ( / (?: [ ^ \s " ] + | " [ ^ " ] * " ) + / g) ;
418
- logger . info ( "Additional parameters refined: " + paramList )
419
- if ( paramList ) {
420
- paramList . forEach ( ( element ) => {
421
- params . push ( element ) ;
422
- } ) ;
423
- }
424
- return params ;
446
+ // If token contains '=', split and clean value
447
+ const eqIndex = token . indexOf ( '=' ) ;
448
+ if ( eqIndex !== - 1 ) {
449
+ const key = token . substring ( 0 , eqIndex ) ;
450
+ let value = token . substring ( eqIndex + 1 ) ;
451
+ if (
452
+ ( value . startsWith ( '"' ) && value . endsWith ( '"' ) ) ||
453
+ ( value . startsWith ( "'" ) && value . endsWith ( "'" ) )
454
+ ) {
455
+ value = value . slice ( 1 , - 1 ) ;
456
+ }
457
+ return `${ key } =${ value } ` ;
458
+ }
459
+
460
+ return token ;
461
+ } ) ;
425
462
}
426
463
464
+
465
+
427
466
getIndexOfBflNode ( bflNodes : CxBFL [ ] , resultNodes : any [ ] ) : number {
428
467
const bflNodeNotFound = - 1 ;
429
468
0 commit comments