Skip to content

Commit fda32f8

Browse files
[DomCrawler] Dont use LIBXML_PARSEHUGE by default
1 parent 2e9e83e commit fda32f8

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)