diff --git a/src/Filters/TwigToPh.php b/src/Filters/TwigToPh.php
index 69ce579..4ff977a 100644
--- a/src/Filters/TwigToPh.php
+++ b/src/Filters/TwigToPh.php
@@ -31,7 +31,7 @@ class TwigToPh extends AbstractHandler {
* @return string
*/
public function transform( $segment ) {
- preg_match_all( '/{{[^<>]+?}}|{%[^<>]+?%}|{#[^<>]+?#}|{[^<>]+?}/', $segment, $html, PREG_SET_ORDER );
+ preg_match_all( '/{{[^<>]+?}}|{%[^<>]+?%}|{#[^<>]+?#}/', $segment, $html, PREG_SET_ORDER );
foreach ( $html as $pos => $twig_variable ) {
//check if inside twig variable there is a tag because in this case shouldn't replace the content with PH tag
if( !strstr($twig_variable[0], Constants::GTPLACEHOLDER) ){
diff --git a/tests/MateCatSubFilteringTest.php b/tests/MateCatSubFilteringTest.php
index b162def..84a1168 100644
--- a/tests/MateCatSubFilteringTest.php
+++ b/tests/MateCatSubFilteringTest.php
@@ -98,28 +98,6 @@ public function testComplexXML()
}
-// /**
-// * Filters BUG, segmentation on HTML ( Should be fixed, anyway we try to cover )
-// * @throws \Exception
-// */
-// public function testComplexBrokenHtmlInXML()
-// {
-// $filter = $this->getFilterInstance();
-//
-// $segment = '%{abb:flag.nolinkvalidation[0]} <div class="panel"> <div class="panel-body"> <p>You can read this article in <a href="/help/article/1381?';
-// $segmentL1 = $filter->fromLayer0ToLayer1( $segment );
-// $segmentL2 = $filter->fromLayer0ToLayer2( $segment );
-//
-// $this->assertEquals( $segment, $filter->fromLayer1ToLayer0( $segmentL1 ) );
-//
-// $string_from_UI = ' You can read this article in <a href="/help/article/1381?';
-//
-// $this->assertEquals( $segment, $filter->fromLayer2ToLayer0( $string_from_UI ) );
-// $this->assertEquals( $segmentL2, $filter->fromLayer1ToLayer2( $segmentL1 ) );
-// $this->assertEquals( $segmentL1, $filter->fromLayer2ToLayer1( $string_from_UI ) );
-//
-// }
-
/**
* @throws \Exception
*/
@@ -243,16 +221,6 @@ public function test_3_HandlingNBSP()
public function testHTMLFromLayer2()
{
$filter = $this->getFilterInstance();
-
- //Original JSON value from Airbnb
- //"<br><br>This will "
-
- //Xliff Value
- //"<br><br>This will "
-
- //Fixed by airbnb plugin in Database
- //"<br><br>This will"
-
$expected_segment = '<b>de %1$s, </b>que';
//Start test
@@ -275,6 +243,17 @@ public function testSprintf()
$this->assertEquals( $segment, $seg_transformed );
}
+ public function testTwigFilterWithSingleBrackets()
+ {
+ $segment = 'Hi {this strings would not be escaped}. Instead {{this one}} is a valid twig expression. Also {%%ciao%%} is valid!';
+ $expected = 'Hi {this strings would not be escaped}. Instead is a valid twig expression. Also is valid!';
+
+ $channel = new Pipeline();
+ $channel->addLast( new TwigToPh() );
+ $seg_transformed = $channel->transform( $segment );
+ $this->assertEquals( $expected, $seg_transformed );
+ }
+
public function testTwigUngreedy()
{
$segment = 'Dear {{customer.first_name}}, This is {{agent.alias}} with Airbnb.';