Skip to content
Snippets Groups Projects

Resolve #3461936: Fix str_replace() called with NULL

1 file
+ 5
0
Compare changes
  • Side-by-side
  • Inline
@@ -471,6 +471,11 @@ class Highlight extends ProcessorPluginBase implements PluginFormInterface {
protected function createExcerpt($text, array $keys) {
// Remove HTML tags <script> and <style> with all of their contents.
$text = preg_replace('#<(style|script).*?>.*?</\1>#is', ' ', $text);
// In case the preg_replace() failed for some reason it's safer to just
// return NULL instead of risking returning Javascript as th excerpt.
if ($text === NULL) {
return NULL;
}
// Prepare text by stripping HTML tags and decoding HTML entities.
$text = strip_tags(str_replace(['<', '>'], [' <', '> '], $text));
Loading