Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a632fe2

Browse files
[DowCrawler] Fix locale-sensitivity of whitespace normalization
1 parent f86f383 commit a632fe2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Symfony/Component/DomCrawler/Crawler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,15 +620,15 @@ public function text(/* string $default = null, bool $normalizeWhitespace = true
620620
$text = $this->getNode(0)->nodeValue;
621621

622622
if (\func_num_args() <= 1) {
623-
if (trim(preg_replace('/(?:\s{2,}+|[^\S ])/', ' ', $text)) !== $text) {
623+
if (trim(preg_replace("/(?:[ \n\r\t\x0C]{2,}+|[\n\r\t\x0C])/", ' ', $text), " \n\r\t\x0C") !== $text) {
624624
@trigger_error(sprintf('"%s()" will normalize whitespaces by default in Symfony 5.0, set the second "$normalizeWhitespace" argument to false to retrieve the non-normalized version of the text.', __METHOD__), \E_USER_DEPRECATED);
625625
}
626626

627627
return $text;
628628
}
629629

630630
if (\func_num_args() > 1 && func_get_arg(1)) {
631-
return trim(preg_replace('/(?:\s{2,}+|[^\S ])/', ' ', $text));
631+
return trim(preg_replace("/(?:[ \n\r\t\x0C]{2,}+|[\n\r\t\x0C])/", ' ', $text), " \n\r\t\x0C");
632632
}
633633

634634
return $text;

0 commit comments

Comments
 (0)