diff --git a/lib/Twig/Environment.php b/lib/Twig/Environment.php index 1a1a933db..7353ff8bd 100644 --- a/lib/Twig/Environment.php +++ b/lib/Twig/Environment.php @@ -641,7 +641,7 @@ class Twig_Environment $compiled = $this->compile($this->parse($this->tokenize($source, $name)), $source); if (isset($source[0])) { - $compiled .= '/* '.str_replace(array("\r\n", "\r", "\n"), "*/\n/* ", str_replace('*/', '*//*', $source))."*/\n"; + $compiled .= '/* '.strtr($source, array('*/' => '*//*', "\r\n" => "*/\n/* ", "\r" => "*/\n/* ", "\n" => "*/\n/* "))."*/\n"; } return $compiled; diff --git a/test/Twig/Tests/EnvironmentTest.php b/test/Twig/Tests/EnvironmentTest.php index 64baecf1f..84af47c81 100644 --- a/test/Twig/Tests/EnvironmentTest.php +++ b/test/Twig/Tests/EnvironmentTest.php @@ -142,7 +142,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase { $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); - $source = "\nbar\n"; + $source = "\r\nbar\n"; $expected = "/* */\n/* bar*/\n/* */\n"; $this->assertContains($expected, $twig->compileSource($source, 'index'));