Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BUG: Fix for #1487

The parser could sometimes generate invalid code if the
source-file-comments were enabled, this moves the comments outside the
html-tag to circumvent these problems, update test as well.
  • Loading branch information...
commit acf2ff8ce655d11c5708f67948bee0667ca9cae1 1 parent c02d7e4
@steffen-maass steffen-maass authored
View
4 tests/view/SSViewerTest.php
@@ -1068,10 +1068,10 @@ public function testRenderWithSourceFileComments() {
$result = $view->process($data);
$expected = '<!doctype html>
-<html><!-- template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsFullSource.ss -->
+<!-- template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsFullSource.ss --><html>
<head></head>
<body></body>
-<!-- end template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsFullSource.ss --></html>
+</html><!-- end template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsFullSource.ss -->
';
$this->assertEquals($result, $expected);
View
12 view/SSTemplateParser.php
@@ -1675,14 +1675,14 @@ function If_IfPart(&$res, $sub) {
function If_ElseIfPart(&$res, $sub) {
$res['php'] .=
'else if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL .
- (isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
+ (isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
'}';
}
function If_ElsePart(&$res, $sub) {
$res['php'] .=
'else { ' . PHP_EOL .
- (isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
+ (isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
'}';
}
@@ -4593,11 +4593,11 @@ static function compileString($string, $templateName = "", $includeDebuggingComm
// Include top level debugging comments if desired
if($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) {
- // If this template is a full HTML page, then put the comments just inside the HTML tag to prevent any IE
- // glitches
+ // If this template is a full HTML page, then put the comments just outside the HTML tag,
+ // this is still no problem for IE as long as the DOCTYPE-declaration is done before this comment
if(stripos($code, "<html") !== false) {
- $code = preg_replace('/(<html[^>]*>)/i', "\\1<!-- template $templateName -->", $code);
- $code = preg_replace('/(<\/html[^>]*>)/i', "<!-- end template $templateName -->\\1", $code);
+ $code = preg_replace('/(<html[^>]*>)/i', "<!-- template $templateName -->\\1", $code);
+ $code = preg_replace('/(<\/html[^>]*>)/i', "\\1<!-- end template $templateName -->", $code);
} else {
$code = str_replace('<?php' . PHP_EOL, '<?php' . PHP_EOL . '$val .= \'<!-- template ' . $templateName .
' -->\';' . "\n", $code);
View
8 view/SSTemplateParser.php.inc
@@ -1047,11 +1047,11 @@ class SSTemplateParser extends Parser {
// Include top level debugging comments if desired
if($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) {
- // If this template is a full HTML page, then put the comments just inside the HTML tag to prevent any IE
- // glitches
+ // If this template is a full HTML page, then put the comments just outside the HTML tag,
+ // this is still no problem for IE as long as the DOCTYPE-declaration is done before this comment
if(stripos($code, "<html") !== false) {
- $code = preg_replace('/(<html[^>]*>)/i', "\\1<!-- template $templateName -->", $code);
- $code = preg_replace('/(<\/html[^>]*>)/i', "<!-- end template $templateName -->\\1", $code);
+ $code = preg_replace('/(<html[^>]*>)/i', "<!-- template $templateName -->\\1", $code);
+ $code = preg_replace('/(<\/html[^>]*>)/i', "\\1<!-- end template $templateName -->", $code);
} else {
$code = str_replace('<?php' . PHP_EOL, '<?php' . PHP_EOL . '$val .= \'<!-- template ' . $templateName .
' -->\';' . "\n", $code);
Please sign in to comment.
Something went wrong with that request. Please try again.