@@ -32,8 +32,8 @@ class ActionObject
32
32
const ACTION_ATTRIBUTE_URL = 'url ' ;
33
33
const ACTION_ATTRIBUTE_SELECTOR = 'selector ' ;
34
34
const ACTION_ATTRIBUTE_VARIABLE_REGEX_PARAMETER = '/\(.+\)/ ' ;
35
- const ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN = '/{{[\w.\[\]() \' ,$ ]+}}/ ' ;
36
- const ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN_WITH_PARAMS = '/{{[\w]+\.[\w]+\([\w ,. \' {$}] +\)}}/ ' ;
35
+ const ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN = '/{{[\w]+\.[\w ]+}}/ ' ;
36
+ const ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN_WITH_PARAMS = '/{{[\w]+\.[\w]+\(. +\)}}/ ' ;
37
37
38
38
/**
39
39
* The unique identifier for the action
@@ -343,18 +343,37 @@ private function stripAndSplitReference($reference)
343
343
}
344
344
345
345
/**
346
- * Returns an array containing all parameters found inside () block of test input.
346
+ * Returns an array containing all parameters found inside () block of test input. Expected delimiter is ', '.
347
347
* Returns null if no parameters were found.
348
348
*
349
349
* @param string $reference
350
350
* @return array|null
351
351
*/
352
352
private function stripAndReturnParameters ($ reference )
353
353
{
354
+ // 'string', or 'string,!@#$%^&*()_+, '
355
+ $ literalParametersRegex = "/'[^']+'/ " ;
356
+ $ postCleanupDelimiter = ":::: " ;
357
+
354
358
preg_match (ActionObject::ACTION_ATTRIBUTE_VARIABLE_REGEX_PARAMETER , $ reference , $ matches );
355
359
if (!empty ($ matches )) {
356
- $ strippedReference = str_replace (') ' , '' , str_replace ('( ' , '' , $ matches [0 ]));
357
- return explode (', ' , $ strippedReference );
360
+ $ strippedReference = ltrim (rtrim ($ matches [0 ], ") " ), "( " );
361
+
362
+ // Pull out all 'string' references, as they can contain 'string with , comma in it'
363
+ preg_match_all ($ literalParametersRegex , $ strippedReference , $ literalReferences );
364
+ $ strippedReference = preg_replace ($ literalParametersRegex , '&&stringReference&& ' , $ strippedReference );
365
+
366
+ // Sanitize 'string, data.field,$persisted.field$' => 'string::::data.field::::$persisted.field$'
367
+ $ strippedReference = preg_replace ('/,/ ' , ', ' , $ strippedReference );
368
+ $ strippedReference = str_replace (', ' , $ postCleanupDelimiter , $ strippedReference );
369
+ $ strippedReference = str_replace (' ' , '' , $ strippedReference );
370
+
371
+ // Replace string references into string, needed to keep sequence
372
+ foreach ($ literalReferences [0 ] as $ key => $ value ) {
373
+ $ strippedReference = preg_replace ('/&&stringReference&&/ ' , $ value , $ strippedReference , 1 );
374
+ }
375
+
376
+ return explode ($ postCleanupDelimiter , $ strippedReference );
358
377
}
359
378
return null ;
360
379
}
0 commit comments