Skip to content
This repository
Browse code

BUG 7362 dont include trailing space in bare string

  • Loading branch information...
commit e160b76df5a0fee256e30c5de17a7cf28b8bd889 1 parent 2664cb2
Hamish Friedlander authored July 23, 2012
6  tests/view/SSViewerTest.php
@@ -392,6 +392,10 @@ function testIfBlocks() {
392 392
 		$this->assertEquals('AD',
393 393
 			$this->render('A<% if Right == Wrong %>B<% else_if RawVal != RawVal %>C<% end_if %>D'));
394 394
 
  395
+		// Bare words with ending space
  396
+		$this->assertEquals('ABC',
  397
+			$this->render('A<% if "RawVal" == RawVal %>B<% end_if %>C'));
  398
+
395 399
 		// Else
396 400
 		$this->assertEquals('ADE',
397 401
 			$this->render('A<% if Right == Wrong %>B<% else_if RawVal != RawVal %>C<% else %>D<% end_if %>E'));
@@ -457,7 +461,7 @@ function testIncludeWithArguments() {
457 461
 
458 462
 		$this->assertEquals(
459 463
 			$this->render('<% include SSViewerTestIncludeWithArguments Arg1=A Bare String, Arg2=B Bare String %>'),
460  
-			'<p>A Bare String</p><p>B Bare String </p>'
  464
+			'<p>A Bare String</p><p>B Bare String</p>'
461 465
 		);
462 466
 
463 467
 		$this->assertEquals(
2  view/SSTemplateParser.php
@@ -1146,7 +1146,7 @@ function Argument_Lookup(&$res, $sub) {
1146 1146
 	
1147 1147
 	function Argument_FreeString(&$res, $sub) {
1148 1148
 		$res['ArgumentMode'] = 'string';
1149  
-		$res['php'] = "'" . str_replace("'", "\\'", $sub['text']) . "'";
  1149
+		$res['php'] = "'" . str_replace("'", "\\'", trim($sub['text'])) . "'";
1150 1150
 	}
1151 1151
 	
1152 1152
 	/* ComparisonOperator: "==" | "!=" | "=" */
2  view/SSTemplateParser.php.inc
@@ -322,7 +322,7 @@ class SSTemplateParser extends Parser {
322 322
 	
323 323
 	function Argument_FreeString(&$res, $sub) {
324 324
 		$res['ArgumentMode'] = 'string';
325  
-		$res['php'] = "'" . str_replace("'", "\\'", $sub['text']) . "'";
  325
+		$res['php'] = "'" . str_replace("'", "\\'", trim($sub['text'])) . "'";
326 326
 	}
327 327
 	
328 328
 	/*!*

0 notes on commit e160b76

Please sign in to comment.
Something went wrong with that request. Please try again.