Skip to content

Commit

Permalink
Merge pull request #13 from mficzel/bugfix/supportSlashesInTextsAndSt…
Browse files Browse the repository at this point in the history
…rings

BUGFIX: Support slashes in texts property
  • Loading branch information
mficzel authored Nov 14, 2018
2 parents 8007067 + ef6d3d0 commit 92d5950
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Classes/Service/AfxService.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected static function astStringToFusion($payload, $indentation = '')
*/
protected static function astTextToFusion($payload, $indentation = '')
{
return '\'' . str_replace('\'', '\\\'', $payload) . '\'';
return '\'' . addslashes($payload) . '\'';
}

/**
Expand Down
34 changes: 34 additions & 0 deletions Tests/Functional/AfxServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,40 @@ public function spacesInsideALineArePreservedAlsoForStrings()
$this->assertEquals($expectedFusion, AfxService::convertAfxToFusion($afxCode));
}

/**
* @test
*/
public function slashesInTextNodesArePreserved()
{
$afxCode = '<h1>\o/</h1>';

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

/**
* @test
*/
public function textsAreEscaped()
{
$afxCode = <<<'EOF'
<h1>foo'bar\baz"bam</h1>
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
Expand Down

0 comments on commit 92d5950

Please sign in to comment.