Skip to content

Commit 92d5950

Browse files
authored
Merge pull request #13 from mficzel/bugfix/supportSlashesInTextsAndStrings
BUGFIX: Support slashes in texts property
2 parents 8007067 + ef6d3d0 commit 92d5950

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

Classes/Service/AfxService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected static function astStringToFusion($payload, $indentation = '')
9393
*/
9494
protected static function astTextToFusion($payload, $indentation = '')
9595
{
96-
return '\'' . str_replace('\'', '\\\'', $payload) . '\'';
96+
return '\'' . addslashes($payload) . '\'';
9797
}
9898

9999
/**

Tests/Functional/AfxServiceTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,40 @@ public function spacesInsideALineArePreservedAlsoForStrings()
600600
$this->assertEquals($expectedFusion, AfxService::convertAfxToFusion($afxCode));
601601
}
602602

603+
/**
604+
* @test
605+
*/
606+
public function slashesInTextNodesArePreserved()
607+
{
608+
$afxCode = '<h1>\o/</h1>';
609+
610+
$expectedFusion = <<<'EOF'
611+
Neos.Fusion:Tag {
612+
tagName = 'h1'
613+
content = '\\o/'
614+
}
615+
EOF;
616+
$this->assertEquals($expectedFusion, AfxService::convertAfxToFusion($afxCode));
617+
}
618+
619+
/**
620+
* @test
621+
*/
622+
public function textsAreEscaped()
623+
{
624+
$afxCode = <<<'EOF'
625+
<h1>foo'bar\baz"bam</h1>
626+
EOF;
627+
628+
$expectedFusion = <<<'EOF'
629+
Neos.Fusion:Tag {
630+
tagName = 'h1'
631+
content = 'foo\'bar\\baz\"bam'
632+
}
633+
EOF;
634+
$this->assertEquals($expectedFusion, AfxService::convertAfxToFusion($afxCode));
635+
}
636+
603637
/**
604638
* @test
605639
* @expectedException \PackageFactory\Afx\Exception

0 commit comments

Comments
 (0)