Skip to content

Commit fe56270

Browse files
authored
Merge pull request #19 from ElementareTeilchen/patch-1
BUGFIX: Support backslashes in string attributes
2 parents 22c0bb3 + ca0dc1a commit fe56270

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-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 astExpressionToFusion($payload, $indentation = '')
9393
*/
9494
protected static function astStringToFusion($payload, $indentation = '')
9595
{
96-
return '\'' . str_replace('\'', '\\\'', $payload) . '\'';
96+
return '\'' . addslashes($payload) . '\'';
9797
}
9898

9999
/**

Tests/Functional/AfxServiceTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,44 @@ public function textsAreEscaped(): void
713713
$this->assertEquals($expectedFusion, AfxService::convertAfxToFusion($afxCode));
714714
}
715715

716+
/**
717+
* @test
718+
*/
719+
public function slashesInStringNodesArePreserved()
720+
{
721+
$afxCode = <<<'EOF'
722+
<h1 class="\\o/">foobar</h1>
723+
EOF;
724+
725+
$expectedFusion = <<<'EOF'
726+
Neos.Fusion:Tag {
727+
tagName = 'h1'
728+
attributes.class = '\\o/'
729+
content = 'foobar'
730+
}
731+
EOF;
732+
$this->assertEquals($expectedFusion, AfxService::convertAfxToFusion($afxCode));
733+
}
734+
735+
/**
736+
* @test
737+
*/
738+
public function stringsAreEscaped()
739+
{
740+
$afxCode = <<<'EOF'
741+
<h1 class="foo\'foo'bar\\baz\"bam\bam">foobar</h1>
742+
EOF;
743+
744+
$expectedFusion = <<<'EOF'
745+
Neos.Fusion:Tag {
746+
tagName = 'h1'
747+
attributes.class = 'foo\'foo\'bar\\baz\"bambam'
748+
content = 'foobar'
749+
}
750+
EOF;
751+
$this->assertEquals($expectedFusion, AfxService::convertAfxToFusion($afxCode));
752+
}
753+
716754
/**
717755
* @test
718756
*/

0 commit comments

Comments
 (0)