Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fcd9c2d

Browse filesBrowse files
bug #47175 [DowCrawler] Fix locale-sensitivity of whitespace normalization (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [DowCrawler] Fix locale-sensitivity of whitespace normalization | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #46822 | License | MIT | Doc PR | - Also aligning with https://infra.spec.whatwg.org/#ascii-whitespace Commits ------- a632fe2 [DowCrawler] Fix locale-sensitivity of whitespace normalization
2 parents 0420d3c + a632fe2 commit fcd9c2d
Copy full SHA for fcd9c2d

File tree

Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-2
lines changed

‎src/Symfony/Component/DomCrawler/Crawler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DomCrawler/Crawler.php
+2-2Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.