: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$attributes = array($attributes);
if (!is_array($this->strip_htmltags) || !in_array($tag, $this->strip_htmltags))
$elements = $document->getElementsByTagName($tag);
foreach ($elements as $element)
foreach ($attributes as $attribute)
if ($element->hasAttribute($attribute))
$value = $this->registry->call('Misc', 'absolutize_url', array($element->getAttribute($attribute), $this->base));
$value = $this->https_url($value);
$element->setAttribute($attribute, $value);
public function do_strip_htmltags($match)
if ($this->encode_instead_of_strip)
if (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
$match[1] = htmlspecialchars($match[1], ENT_COMPAT, 'UTF-8');
$match[2] = htmlspecialchars($match[2], ENT_COMPAT, 'UTF-8');
return "<$match[1]$match[2]>$match[3]</$match[1]>";
return htmlspecialchars($match[0], ENT_COMPAT, 'UTF-8');
elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style')))
protected function strip_tag($tag, $document, $xpath, $type)
$elements = $xpath->query('body//' . $tag);
if ($this->encode_instead_of_strip)
foreach ($elements as $element)
$fragment = $document->createDocumentFragment();
// For elements which aren't script or style, include the tag itself
if (!in_array($tag, array('script', 'style')))
if ($element->hasAttributes())
foreach ($element->attributes as $name => $attr)
// In XHTML, empty values should never exist, so we repeat the value
if (empty($value) && ($type & SIMPLEPIE_CONSTRUCT_XHTML))
// For HTML, empty is fine
elseif (empty($value) && ($type & SIMPLEPIE_CONSTRUCT_HTML))
// Standard attribute text
$attrs[] = $name . '="' . $attr->value . '"';
$text .= ' ' . implode(' ', $attrs);
$fragment->appendChild(new DOMText($text));
$number = $element->childNodes->length;
for ($i = $number; $i > 0; $i--)
$child = $element->childNodes->item(0);
$fragment->appendChild($child);
if (!in_array($tag, array('script', 'style')))
$fragment->appendChild(new DOMText('</' . $tag . '>'));
$element->parentNode->replaceChild($fragment, $element);
elseif (in_array($tag, array('script', 'style')))
foreach ($elements as $element)
$element->parentNode->removeChild($element);
foreach ($elements as $element)
$fragment = $document->createDocumentFragment();
$number = $element->childNodes->length;
for ($i = $number; $i > 0; $i--)
$child = $element->childNodes->item(0);
$fragment->appendChild($child);
$element->parentNode->replaceChild($fragment, $element);
protected function strip_attr($attrib, $xpath)
$elements = $xpath->query('//*[@' . $attrib . ']');
foreach ($elements as $element)
$element->removeAttribute($attrib);
protected function add_attr($tag, $valuePairs, $document)
$elements = $document->getElementsByTagName($tag);
foreach ($elements as $element)
foreach ($valuePairs as $attrib => $value)
$element->setAttribute($attrib, $value);