[5.x] Bugfix quoting for InteractsWithElements::value #735
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This handles JS quoting a little bit better.
We found the bug for quoting of JS by calling the method InteractsWithElements::value.
If you call this method with following arguments
will break the generated JS code.
Then we found this pull request: #693
But the pull request does not fully fix this problem. If you us an value, which has an line break, then the generated JS Code will break again.
This pull request fix this completely.
No breaking changes
The value function does not correctly escape the contents of $value variable as a result if someone passes a string even with a escaped single quote, the code breaks because value is assigned using single quotes on line 69 argument passed to executeScript,
"document.querySelector('{$selector}').value = '{$value}';"
$browser->value('my'Field', "long text\nwith line breaks");
Current output of the script:
Expected output of the script:
Please take also a closer look at #734