diff --git a/Classes/Service/AfxService.php b/Classes/Service/AfxService.php index 93c18b5..045fb14 100644 --- a/Classes/Service/AfxService.php +++ b/Classes/Service/AfxService.php @@ -93,7 +93,7 @@ protected static function astStringToFusion($payload, $indentation = '') */ protected static function astTextToFusion($payload, $indentation = '') { - return '\'' . str_replace('\'', '\\\'', $payload) . '\''; + return '\'' . addslashes($payload) . '\''; } /** diff --git a/Tests/Functional/AfxServiceTest.php b/Tests/Functional/AfxServiceTest.php index 675a9c6..54f8a99 100644 --- a/Tests/Functional/AfxServiceTest.php +++ b/Tests/Functional/AfxServiceTest.php @@ -600,6 +600,40 @@ public function spacesInsideALineArePreservedAlsoForStrings() $this->assertEquals($expectedFusion, AfxService::convertAfxToFusion($afxCode)); } + /** + * @test + */ + public function slashesInTextNodesArePreserved() + { + $afxCode = '

\o/

'; + + $expectedFusion = <<<'EOF' +Neos.Fusion:Tag { + tagName = 'h1' + content = '\\o/' +} +EOF; + $this->assertEquals($expectedFusion, AfxService::convertAfxToFusion($afxCode)); + } + + /** + * @test + */ + public function textsAreEscaped() + { + $afxCode = <<<'EOF' +

foo'bar\baz"bam

+EOF; + + $expectedFusion = <<<'EOF' +Neos.Fusion:Tag { + tagName = 'h1' + content = 'foo\'bar\\baz\"bam' +} +EOF; + $this->assertEquals($expectedFusion, AfxService::convertAfxToFusion($afxCode)); + } + /** * @test * @expectedException \PackageFactory\Afx\Exception