mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
8dd644d25d
Namespace all templates Move difflib and BBCodeParser2 to thirdparty Remove deprecated API marked for removal in 4.0
33 lines
882 B
PHP
33 lines
882 B
PHP
<?php
|
|
|
|
namespace SilverStripe\View\Parsers;
|
|
|
|
class SS_HTML4Value extends SS_HTMLValue
|
|
{
|
|
|
|
/**
|
|
* @param string $content
|
|
* @return bool
|
|
*/
|
|
public function setContent($content)
|
|
{
|
|
// Ensure that \r (carriage return) characters don't get replaced with " " entity by DOMDocument
|
|
// This behaviour is apparently XML spec, but we don't want this because it messes up the HTML
|
|
$content = str_replace(chr(13), '', $content);
|
|
|
|
// Reset the document if we're in an invalid state for some reason
|
|
if (!$this->isValid()) {
|
|
$this->setDocument(null);
|
|
}
|
|
|
|
$errorState = libxml_use_internal_errors(true);
|
|
$result = $this->getDocument()->loadHTML(
|
|
'<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head>' .
|
|
"<body>$content</body></html>"
|
|
);
|
|
libxml_clear_errors();
|
|
libxml_use_internal_errors($errorState);
|
|
return $result;
|
|
}
|
|
}
|