mirror of
https://github.com/j0k3r/php-readability.git
synced 2026-09-27 06:26:17 +00:00
Strip script and style tags through ::clean() method instead of preg_replace
Huge tags can lead to a failure of preg_replace, thus erasing the whole fetched content. Fixes https://github.com/wallabag/wallabag/issues/5847 Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
This commit is contained in:
+3
-4
@@ -137,10 +137,6 @@ class Readability implements LoggerAwareInterface
|
||||
protected $useTidy;
|
||||
// raw HTML filters
|
||||
protected $pre_filters = [
|
||||
// remove obvious scripts
|
||||
'!<script[^>]*>(.*?)</script>!is' => '',
|
||||
// remove obvious styles
|
||||
'!<style[^>]*>(.*?)</style>!is' => '',
|
||||
// remove spans as we redefine styles and they're probably special-styled
|
||||
'!</?span[^>]*>!is' => '',
|
||||
// HACK: firewall-filtered content
|
||||
@@ -397,6 +393,9 @@ class Readability implements LoggerAwareInterface
|
||||
|
||||
$this->logger->debug($this->lightClean ? 'Light clean enabled.' : 'Standard clean enabled.');
|
||||
|
||||
$this->clean($articleContent, 'style');
|
||||
$this->clean($articleContent, 'script');
|
||||
|
||||
$this->cleanStyles($articleContent);
|
||||
$this->killBreaks($articleContent);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user