diff --git a/integration/HTMLValue.php b/integration/HTMLValue.php index 312ba2807..735d749b4 100755 --- a/integration/HTMLValue.php +++ b/integration/HTMLValue.php @@ -45,11 +45,10 @@ class SS_HTMLValue extends ViewableData { * @return bool */ public function setContent($content) { - // Ensure that window-style newlines don't get replaced with " " entity by DOMDocument - if (PHP_EOL == "\n") { - $content = str_replace("\r\n", PHP_EOL, $content); - } - + // Ensure that \r (carriage return) characters don't get replaced with " " entity by DOMDocument + // apparently it's in the XML standard, but that messes it up because we're using HTML + $content = str_replace(chr(13), '', $content); + return @$this->getDocument()->loadHTML( '' . "$content" diff --git a/tests/integration/HTMLValueTest.php b/tests/integration/HTMLValueTest.php index 0c984a8b3..ecfe46c0d 100755 --- a/tests/integration/HTMLValueTest.php +++ b/tests/integration/HTMLValueTest.php @@ -40,8 +40,9 @@ class SS_HTMLValueTest extends SapphireTest { public function testMixedNewlines() { $value = new SS_HTMLValue(); - $eol = PHP_EOL; - $value->setContent("

paragraph

{$eol}"); + $eol = "\n"; + $platformEOL = PHP_EOL; // native EOL for platform. Windows is \r\n (CR-LF). UNIX is LF + $value->setContent("

paragraph

{$platformEOL}"); $this->assertEquals( "

paragraph

{$eol}", $value->getContent(),