From c0c0c76dd27b64930179769a4f7d89a0e96667e9 Mon Sep 17 00:00:00 2001 From: hanshenrik Date: Wed, 13 Dec 2023 13:34:02 +0100 Subject: [PATCH] prettier run-time error messages --- src/Dom/Selector/XPathSelector.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Dom/Selector/XPathSelector.php b/src/Dom/Selector/XPathSelector.php index d76f55b..71981ee 100644 --- a/src/Dom/Selector/XPathSelector.php +++ b/src/Dom/Selector/XPathSelector.php @@ -19,11 +19,11 @@ public function __construct(string $expression) public function expressionCount(): string { - return 'document.evaluate('.\json_encode($this->expression, \JSON_THROW_ON_ERROR).', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotLength'; + return 'document.evaluate('.\json_encode($this->expression, \JSON_THROW_ON_ERROR | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE).', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotLength'; } public function expressionFindOne(int $position): string { - return 'document.evaluate('.\json_encode($this->expression."[{$position}]", \JSON_THROW_ON_ERROR).', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue'; + return 'document.evaluate('.\json_encode($this->expression."[{$position}]", \JSON_THROW_ON_ERROR | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE).', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue'; } }