aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/simplepie/simplepie/library/SimplePie/Parser.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/simplepie/simplepie/library/SimplePie/Parser.php')
-rw-r--r--vendor/simplepie/simplepie/library/SimplePie/Parser.php24
1 files changed, 21 insertions, 3 deletions
diff --git a/vendor/simplepie/simplepie/library/SimplePie/Parser.php b/vendor/simplepie/simplepie/library/SimplePie/Parser.php
index 4efdf41a7..3813b74b2 100644
--- a/vendor/simplepie/simplepie/library/SimplePie/Parser.php
+++ b/vendor/simplepie/simplepie/library/SimplePie/Parser.php
@@ -164,12 +164,30 @@ class SimplePie_Parser
xml_set_element_handler($xml, 'tag_open', 'tag_close');
// Parse!
- if (!xml_parse($xml, $data, true))
+ $wrapper = @is_writable(sys_get_temp_dir()) ? 'php://temp' : 'php://memory';
+ if (($stream = fopen($wrapper, 'r+')) &&
+ fwrite($stream, $data) &&
+ rewind($stream))
+ {
+ //Parse by chunks not to use too much memory
+ do
+ {
+ $stream_data = fread($stream, 1048576);
+ if (!xml_parse($xml, $stream_data === false ? '' : $stream_data, feof($stream)))
+ {
+ $this->error_code = xml_get_error_code($xml);
+ $this->error_string = xml_error_string($this->error_code);
+ $return = false;
+ break;
+ }
+ } while (!feof($stream));
+ fclose($stream);
+ }
+ else
{
- $this->error_code = xml_get_error_code($xml);
- $this->error_string = xml_error_string($this->error_code);
$return = false;
}
+
$this->current_line = xml_get_current_line_number($xml);
$this->current_column = xml_get_current_column_number($xml);
$this->current_byte = xml_get_current_byte_index($xml);