aboutsummaryrefslogtreecommitdiffstats
path: root/lib/simplepie/library/SimplePie/Parser.php
diff options
context:
space:
mode:
authorfilip <filip.komar@gmail.com>2021-04-13 12:41:24 +0200
committerfilip <filip.komar@gmail.com>2021-04-13 12:41:24 +0200
commite065d637d9aff8e59e44d5c0553fd4c50509951c (patch)
tree17f131cbb670bae8767efc75e1c7e4c11d5be287 /lib/simplepie/library/SimplePie/Parser.php
parent63276079bbaa3c53e1fdfe3ab44e97a16c1741f9 (diff)
downloadwww-e065d637d9aff8e59e44d5c0553fd4c50509951c.tar
www-e065d637d9aff8e59e44d5c0553fd4c50509951c.tar.gz
www-e065d637d9aff8e59e44d5c0553fd4c50509951c.tar.bz2
www-e065d637d9aff8e59e44d5c0553fd4c50509951c.tar.xz
www-e065d637d9aff8e59e44d5c0553fd4c50509951c.zip
update SimplePie for compatibility php 7.4 and 8
Diffstat (limited to 'lib/simplepie/library/SimplePie/Parser.php')
-rw-r--r--lib/simplepie/library/SimplePie/Parser.php30
1 files changed, 24 insertions, 6 deletions
diff --git a/lib/simplepie/library/SimplePie/Parser.php b/lib/simplepie/library/SimplePie/Parser.php
index 3cef2287d..3813b74b2 100644
--- a/lib/simplepie/library/SimplePie/Parser.php
+++ b/lib/simplepie/library/SimplePie/Parser.php
@@ -5,7 +5,7 @@
* A PHP-Based RSS and Atom Feed Framework.
* Takes the hard work out of managing a complete RSS/Atom solution.
*
- * Copyright (c) 2004-2016, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
+ * Copyright (c) 2004-2016, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
@@ -33,9 +33,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*
* @package SimplePie
- * @copyright 2004-2016 Ryan Parman, Geoffrey Sneddon, Ryan McCue
+ * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
* @author Ryan Parman
- * @author Geoffrey Sneddon
+ * @author Sam Sneddon
* @author Ryan McCue
* @link http://simplepie.org/ SimplePie
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
@@ -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);