Skip to content

Commit 5b577dd

Browse files
committed
bug symfony#17986 [DomCrawler] Dont use LIBXML_PARSEHUGE by default (nicolas-grekas)
This PR was merged into the 2.3 branch. Discussion ---------- [DomCrawler] Dont use LIBXML_PARSEHUGE by default | Q | A | ------------- | --- | Branch | 2.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | no | Fixed tickets | symfony#16873, symfony#17956 | License | MIT | Doc PR | - Because of http://symfony.com/blog/security-release-symfony-2-0-17-released Commits ------- fda32f8 [DomCrawler] Dont use LIBXML_PARSEHUGE by default
2 parents 9a4bf1e + fda32f8 commit 5b577dd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Symfony/Component/DomCrawler/Crawler.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,11 @@ function ($m) {
219219
*
220220
* @param string $content The XML content
221221
* @param string $charset The charset
222+
* @param int $options Bitwise OR of the libxml option constants
223+
* LIBXML_PARSEHUGE is dangerous, see
224+
* http://symfony.com/blog/security-release-symfony-2-0-17-released
222225
*/
223-
public function addXmlContent($content, $charset = 'UTF-8')
226+
public function addXmlContent($content, $charset = 'UTF-8', $options = LIBXML_NONET)
224227
{
225228
$internalErrors = libxml_use_internal_errors(true);
226229
$disableEntities = libxml_disable_entity_loader(true);
@@ -230,7 +233,7 @@ public function addXmlContent($content, $charset = 'UTF-8')
230233

231234
if ('' !== trim($content)) {
232235
// remove the default namespace to make XPath expressions simpler
233-
@$dom->loadXML(str_replace('xmlns', 'ns', $content), LIBXML_NONET | (defined('LIBXML_PARSEHUGE') ? LIBXML_PARSEHUGE : 0));
236+
@$dom->loadXML(str_replace('xmlns', 'ns', $content), $options);
234237
}
235238

236239
libxml_use_internal_errors($internalErrors);

0 commit comments

Comments
 (0)