From 6338818e9c35e56cd89f5ad79c64b4558da81e67 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Mon, 18 Nov 2024 22:13:52 +0100 Subject: [PATCH 1/2] Updated target.php to new PHP-Parser version --- tools/fuzzing/target.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/fuzzing/target.php b/tools/fuzzing/target.php index 8cbd619c16..c1bb426ed4 100644 --- a/tools/fuzzing/target.php +++ b/tools/fuzzing/target.php @@ -104,7 +104,7 @@ public function leaveNode(PhpParser\Node $node) { $stmts = $parser->parse($input); $printed = $prettyPrinter->prettyPrintFile($stmts); - $visitor->setTokens($lexer->getTokens()); + $visitor->setTokens($lexer->tokenize($input)); $stmts = $traverser->traverse($stmts); if ($visitor->hasProblematicConstruct) { return; @@ -116,7 +116,7 @@ public function leaveNode(PhpParser\Node $node) { throw new Error("Failed to parse pretty printer output"); } - $visitor->setTokens($lexer->getTokens()); + $visitor->setTokens($lexer->tokenize($printed)); $printedStmts = $traverser->traverse($printedStmts); $same = $nodeDumper->dump($stmts) == $nodeDumper->dump($printedStmts); if (!$same && !preg_match('/<\?php<\?php/i', $input)) { From d2a5cf6659423fa8187086ed73c1d18171af65d3 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Sun, 24 Nov 2024 01:37:31 +0100 Subject: [PATCH 2/2] Removed reudndant token generation --- tools/fuzzing/target.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/fuzzing/target.php b/tools/fuzzing/target.php index c1bb426ed4..7638af23c7 100644 --- a/tools/fuzzing/target.php +++ b/tools/fuzzing/target.php @@ -104,7 +104,7 @@ public function leaveNode(PhpParser\Node $node) { $stmts = $parser->parse($input); $printed = $prettyPrinter->prettyPrintFile($stmts); - $visitor->setTokens($lexer->tokenize($input)); + $visitor->setTokens($parser->getTokens()); $stmts = $traverser->traverse($stmts); if ($visitor->hasProblematicConstruct) { return; @@ -116,7 +116,7 @@ public function leaveNode(PhpParser\Node $node) { throw new Error("Failed to parse pretty printer output"); } - $visitor->setTokens($lexer->tokenize($printed)); + $visitor->setTokens($parser->getTokens()); $printedStmts = $traverser->traverse($printedStmts); $same = $nodeDumper->dump($stmts) == $nodeDumper->dump($printedStmts); if (!$same && !preg_match('/<\?php<\?php/i', $input)) {