From 23c1dda1b687bfc8383a808bb6ded6bf2e26b1bc Mon Sep 17 00:00:00 2001 From: NanoSector Date: Thu, 2 Feb 2023 11:10:14 +0100 Subject: [PATCH] [Crawler] Fix regression where cdata nodes will return empty string --- src/Symfony/Component/DomCrawler/Crawler.php | 2 +- .../Component/DomCrawler/Tests/AbstractCrawlerTestCase.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index 274aeee5fc803..8274ee3ee5bf3 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -588,7 +588,7 @@ public function innerText(/* bool $normalizeWhitespace = true */): string $normalizeWhitespace = 1 <= \func_num_args() ? func_get_arg(0) : true; foreach ($this->getNode(0)->childNodes as $childNode) { - if (\XML_TEXT_NODE !== $childNode->nodeType) { + if (\XML_TEXT_NODE !== $childNode->nodeType && \XML_CDATA_SECTION_NODE !== $childNode->nodeType) { continue; } if (!$normalizeWhitespace) { diff --git a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php index e682ff405a349..2a227b10574f9 100644 --- a/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php +++ b/src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php @@ -377,6 +377,12 @@ public static function provideInnerTextExamples() '', ' ', ], + [ + '//*[@id="complex-elements"]/*[@class="six"]', + 'console.log("Test JavaScript content");', + 'console.log("Test JavaScript content");', + ' console.log("Test JavaScript content"); ', + ], ]; } @@ -1311,6 +1317,7 @@ public function createTestCrawler($uri = null)
Parent text Child text Parent text
Child text
Child text Another child
+ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy