Skip to content

Commit 55c9ee4

Browse files
committed
MQE-1153: ExecuteJS javascript escaping matches persisted data
- Updated Regular expression for executeJS to be stricter for escaping characters
1 parent e95107f commit 55c9ee4

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

dev/tests/verification/Resources/ExecuteJsEscapingTest.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,7 @@ class ExecuteJsEscapingTestCest
3131
{
3232
$javaVariableEscape = $I->executeJS("return \$javascriptVariable");
3333
$mftfVariableNotEscaped = $I->executeJS("return {$doNotEscape}");
34+
$persistedDataNotEscaped = $I->executeJS("return " . $persisted->getCreatedDataByName('data'));
35+
$hookPersistedDataNotEscaped = $I->executeJS("return " . $this->persisted->getCreatedDataByName('data'));
3436
}
3537
}

dev/tests/verification/TestModule/Test/ExecuteJsTest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@
1111
<test name="ExecuteJsEscapingTest">
1212
<executeJS function="return $javascriptVariable" stepKey="javaVariableEscape"/>
1313
<executeJS function="return {$doNotEscape}" stepKey="mftfVariableNotEscaped"/>
14+
<executeJS function="return $persisted.data$" stepKey="persistedDataNotEscaped"/>
15+
<executeJS function="return $$persisted.data$$" stepKey="hookPersistedDataNotEscaped"/>
1416
</test>
1517
</tests>

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ public function generateStepsPhp($actionObjects, $hookObject = false, $actor = "
620620
}
621621
// turn $javaVariable => \$javaVariable but not {$mftfVariable}
622622
if ($actionObject->getType() == "executeJS") {
623-
$function = preg_replace('/(?<!{)(\$[\w\d_]+)/', '\\\\$1', $function);
623+
$function = preg_replace('/(?<!{)(\$[A-z._]+)(?![A-z.]*+\$)/', '\\\\$1', $function);
624624
}
625625
}
626626

0 commit comments

Comments
 (0)