Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1.10] Fix xpath php-string-to-javascript-string (#576)
* fix xpath php-string-to-javascript-string TL;DR: addslashes() is not the correct way to convert a php-string to a javascript string. json_encode() is. For example, addslashes will fail on the PHP string "foo".chr(10)."bar" , the old addslashes() will convert it into "foo bar" which is a javascript syntax error. Previously this code would fail: $str = "foo".chr(10)."bar"; $xps = new XPathSelector("//span[contains(text(),'" . $str . "')]"); var_dump($xps->expressionCount()); it would generate a javascript syntax error: string(134) "document.evaluate("//span[contains(text(),\'foo bar\')]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshot Length" now it generates legal javascript: string(135) "document.evaluate("\/\/span[contains(text(),'foo\nbar')]", document , null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotLength" * styling * prettier run-time error messages
- Loading branch information