diff --git a/tests/view/SSViewerTest.php b/tests/view/SSViewerTest.php index f816ba1ddd2..aae7951b0b6 100644 --- a/tests/view/SSViewerTest.php +++ b/tests/view/SSViewerTest.php @@ -59,11 +59,23 @@ public function testRequirements() { public function testComments() { $output = $this->render(<<This is some content<%-- this is another comment --%>Final content +<%-- Alone multi + line comment --%> +Some more content +Mixing content and <%-- multi + line comment --%> Final final +content SS ); + $shouldbe = <<assertEquals("This is my templateThis is some contentFinal content", - preg_replace("/\n?\n?/U",'',$output)); + $this->assertEquals($shouldbe, $output); } public function testBasicText() { diff --git a/view/SSTemplateParser.php b/view/SSTemplateParser.php index 08c319a08fc..d2f16a90ea0 100644 --- a/view/SSTemplateParser.php +++ b/view/SSTemplateParser.php @@ -3939,7 +3939,7 @@ function match_Comment ($stack = array()) { $result = $res_671; $this->pos = $pos_671; } - if (( $subres = $this->rx( '/./' ) ) !== FALSE) { $result["text"] .= $subres; } + if (( $subres = $this->rx( '/(?s)./' ) ) !== FALSE) { $result["text"] .= $subres; } else { $_673 = FALSE; break; } $_673 = TRUE; break; } diff --git a/view/SSTemplateParser.php.inc b/view/SSTemplateParser.php.inc index 45a4650b4b2..151e24b6136 100644 --- a/view/SSTemplateParser.php.inc +++ b/view/SSTemplateParser.php.inc @@ -947,7 +947,7 @@ class SSTemplateParser extends Parser { # This is used to remove template comments - Comment: "<%--" (!"--%>" /./)+ "--%>" + Comment: "<%--" (!"--%>" /(?s)./)+ "--%>" */ function Comment__construct(&$res) { $res['php'] = '';