summaryrefslogtreecommitdiff
path: root/src/HTMLParser.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/HTMLParser.php')
-rw-r--r--src/HTMLParser.php7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/HTMLParser.php b/src/HTMLParser.php
index f1c3d3e..27dd8e5 100644
--- a/src/HTMLParser.php
+++ b/src/HTMLParser.php
@@ -97,6 +97,7 @@ class HTMLParser
'fixRelativeURLs' => false,
'substituteEntities' => true,
'normalizeEntities' => false,
+ 'summonCthulhu' => false,
'originalURL' => 'http://fakehost',
];
@@ -214,6 +215,10 @@ class HTMLParser
$html = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8');
}
+ if ($this->getConfig()->getOption('summonCthulhu')) {
+ $html = preg_replace('/<script\b[^>]*>([\s\S]*?)<\/script>/', '', $html);
+ }
+
// Prepend the XML tag to avoid having issues with special characters. Should be harmless.
$dom->loadHTML('<?xml encoding="UTF-8">' . $html);
$dom->encoding = 'UTF-8';
@@ -463,7 +468,7 @@ class HTMLParser
}
if (array_key_exists('og:image', $values) || array_key_exists('twitter:image', $values)) {
- $metadata['image'] = ($values['og:image']) ? $values['og:image'] : $values['twitter:image'];
+ $metadata['image'] = array_key_exists('og:image', $values) ? $values['og:image'] : $values['twitter:image'];
} else {
$metadata['image'] = null;
}