diff --git a/tests/view/SSViewerTest.php b/tests/view/SSViewerTest.php index 9b75ffb43..bb68870fa 100644 --- a/tests/view/SSViewerTest.php +++ b/tests/view/SSViewerTest.php @@ -392,6 +392,10 @@ after') $this->assertEquals('AD', $this->render('A<% if Right == Wrong %>B<% else_if RawVal != RawVal %>C<% end_if %>D')); + // Bare words with ending space + $this->assertEquals('ABC', + $this->render('A<% if "RawVal" == RawVal %>B<% end_if %>C')); + // Else $this->assertEquals('ADE', $this->render('A<% if Right == Wrong %>B<% else_if RawVal != RawVal %>C<% else %>D<% end_if %>E')); @@ -457,7 +461,7 @@ after') $this->assertEquals( $this->render('<% include SSViewerTestIncludeWithArguments Arg1=A Bare String, Arg2=B Bare String %>'), - '
A Bare String
B Bare String
' + 'A Bare String
B Bare String
' ); $this->assertEquals( diff --git a/view/SSTemplateParser.php b/view/SSTemplateParser.php index 867c018b6..edc5e8d95 100644 --- a/view/SSTemplateParser.php +++ b/view/SSTemplateParser.php @@ -1146,7 +1146,7 @@ class SSTemplateParser extends Parser { function Argument_FreeString(&$res, $sub) { $res['ArgumentMode'] = 'string'; - $res['php'] = "'" . str_replace("'", "\\'", $sub['text']) . "'"; + $res['php'] = "'" . str_replace("'", "\\'", trim($sub['text'])) . "'"; } /* ComparisonOperator: "==" | "!=" | "=" */ diff --git a/view/SSTemplateParser.php.inc b/view/SSTemplateParser.php.inc index 0317ed2ce..e7ffbe9b7 100644 --- a/view/SSTemplateParser.php.inc +++ b/view/SSTemplateParser.php.inc @@ -322,7 +322,7 @@ class SSTemplateParser extends Parser { function Argument_FreeString(&$res, $sub) { $res['ArgumentMode'] = 'string'; - $res['php'] = "'" . str_replace("'", "\\'", $sub['text']) . "'"; + $res['php'] = "'" . str_replace("'", "\\'", trim($sub['text'])) . "'"; } /*!*