From 642601413df48e7e327ef2a4fc135d1bce4f820c Mon Sep 17 00:00:00 2001 From: Mauro Cassani Date: Mon, 6 Sep 2021 15:16:08 +0200 Subject: [PATCH] revert to v1.0.11 --- src/Filters/SubFilteredPhToHtml.php | 1 + tests/MateCatSubFilteringTest.php | 112 ++++++++++++++-------------- 2 files changed, 57 insertions(+), 56 deletions(-) diff --git a/src/Filters/SubFilteredPhToHtml.php b/src/Filters/SubFilteredPhToHtml.php index 01f8efe..830a15f 100644 --- a/src/Filters/SubFilteredPhToHtml.php +++ b/src/Filters/SubFilteredPhToHtml.php @@ -24,6 +24,7 @@ public function transform( $segment ){ preg_match_all( '||siU', $segment, $html, PREG_SET_ORDER ); // Ungreedy foreach ( $html as $subfilter_tag ) { $value = base64_decode( $subfilter_tag[ 1 ] ); + $value = html_entity_decode( $value, ENT_NOQUOTES | ENT_XML1 ); $segment = str_replace( $subfilter_tag[0], $value, $segment ); } diff --git a/tests/MateCatSubFilteringTest.php b/tests/MateCatSubFilteringTest.php index 60e5b67..2cee36c 100644 --- a/tests/MateCatSubFilteringTest.php +++ b/tests/MateCatSubFilteringTest.php @@ -680,61 +680,61 @@ public function testPhTagsWithoutDataRef() $this->assertEquals($back_to_db_segment, $db_segment); } - public function testXTags() - { - $Filter = MateCatFilter::getInstance( new FeatureSet(), 'en-EN','et-ET', [] ); - - $db_segment = '<x id="3"/>Primary Care Facilities<x id="7"/>'; - $expected_l1_segment = 'Primary Care Facilities'; - $expected_l2_segment = '<ph id="mtc_1" equiv-text="base64:Jmx0O3ggaWQ9IjMiLyZndDs="/>Primary Care Facilities<ph id="mtc_2" equiv-text="base64:Jmx0O3ggaWQ9IjciLyZndDs="/>'; - - $l1_segment = $Filter->fromLayer0ToLayer1( $db_segment ); - $l2_segment = $Filter->fromLayer1ToLayer2( $l1_segment ); - - $this->assertEquals($l1_segment, $expected_l1_segment); - $this->assertEquals($l2_segment, $expected_l2_segment); - - $back_to_db_segment = $Filter->fromLayer1ToLayer0($l1_segment); - - $this->assertEquals($back_to_db_segment, $db_segment); - } - - public function testWithComplexUrls() - { - $Filter = MateCatFilter::getInstance( new FeatureSet(), 'en-EN','et-ET', [] ); - - $db_segment = '<li>Bergamo: <a href="http://www.comune.bergamo.it/servizi/Menu/dinamica.aspx?idSezione=3780&#38;idArea=1182&#38;idCat=555&#38;ID=28395&#38;TipoElemento=categoria" target="_blank">Italian</a> </li> 󠄀'; - $expected_l1_segment = 'Bergamo: Italian 󠄀'; - $expected_l2_segment = '<ph id="mtc_1" equiv-text="base64:Jmx0O2xpJmd0Ow=="/>Bergamo: <ph id="mtc_2" equiv-text="base64:Jmx0O2EgaHJlZj0iaHR0cDovL3d3dy5jb211bmUuYmVyZ2Ftby5pdC9zZXJ2aXppL01lbnUvZGluYW1pY2EuYXNweD9pZFNlemlvbmU9Mzc4MCZhbXA7IzM4O2lkQXJlYT0xMTgyJmFtcDsjMzg7aWRDYXQ9NTU1JmFtcDsjMzg7SUQ9MjgzOTUmYW1wOyMzODtUaXBvRWxlbWVudG89Y2F0ZWdvcmlhIiB0YXJnZXQ9Il9ibGFuayImZ3Q7"/>Italian<ph id="mtc_3" equiv-text="base64:Jmx0Oy9hJmd0Ow=="/> <ph id="mtc_4" equiv-text="base64:Jmx0Oy9saSZndDs="/>##$_0A$##󠄀'; - - $l1_segment = $Filter->fromLayer0ToLayer1( $db_segment ); - $l2_segment = $Filter->fromLayer1ToLayer2( $l1_segment ); - - $this->assertEquals($l1_segment, $expected_l1_segment); - $this->assertEquals($l2_segment, $expected_l2_segment); - - $back_to_db_segment = $Filter->fromLayer1ToLayer0($l1_segment); - - $this->assertEquals($back_to_db_segment, $db_segment); - - } - - public function testWithEncodedText() - { - $Filter = MateCatFilter::getInstance( new FeatureSet(), 'en-EN','et-ET', [] ); - - $db_segment = '<x id="3"/>Primary Care Facilities<x id="7"/>'; - $expected_l1_segment = 'Primary Care Facilities'; - $expected_l2_segment = '<ph id="mtc_1" equiv-text="base64:Jmx0O3ggaWQ9IjMiLyZndDs="/>Primary Care Facilities<ph id="mtc_2" equiv-text="base64:Jmx0O3ggaWQ9IjciLyZndDs="/>'; - - $l1_segment = $Filter->fromLayer0ToLayer1( $db_segment ); - $l2_segment = $Filter->fromLayer1ToLayer2( $l1_segment ); - - $this->assertEquals($l1_segment, $expected_l1_segment); - $this->assertEquals($l2_segment, $expected_l2_segment); - - $back_to_db_segment = $Filter->fromLayer1ToLayer0($l1_segment); +// public function testXTags() +// { +// $Filter = MateCatFilter::getInstance( new FeatureSet(), 'en-EN','et-ET', [] ); +// +// $db_segment = '<x id="3"/>Primary Care Facilities<x id="7"/>'; +// $expected_l1_segment = 'Primary Care Facilities'; +// $expected_l2_segment = '<ph id="mtc_1" equiv-text="base64:Jmx0O3ggaWQ9IjMiLyZndDs="/>Primary Care Facilities<ph id="mtc_2" equiv-text="base64:Jmx0O3ggaWQ9IjciLyZndDs="/>'; +// +// $l1_segment = $Filter->fromLayer0ToLayer1( $db_segment ); +// $l2_segment = $Filter->fromLayer1ToLayer2( $l1_segment ); +// +// $this->assertEquals($l1_segment, $expected_l1_segment); +// $this->assertEquals($l2_segment, $expected_l2_segment); +// +// $back_to_db_segment = $Filter->fromLayer1ToLayer0($l1_segment); +// +// $this->assertEquals($back_to_db_segment, $db_segment); +// } +// +// public function testWithComplexUrls() +// { +// $Filter = MateCatFilter::getInstance( new FeatureSet(), 'en-EN','et-ET', [] ); +// +// $db_segment = '<li>Bergamo: <a href="http://www.comune.bergamo.it/servizi/Menu/dinamica.aspx?idSezione=3780&#38;idArea=1182&#38;idCat=555&#38;ID=28395&#38;TipoElemento=categoria" target="_blank">Italian</a> </li> 󠄀'; +// $expected_l1_segment = 'Bergamo: Italian 󠄀'; +// $expected_l2_segment = '<ph id="mtc_1" equiv-text="base64:Jmx0O2xpJmd0Ow=="/>Bergamo: <ph id="mtc_2" equiv-text="base64:Jmx0O2EgaHJlZj0iaHR0cDovL3d3dy5jb211bmUuYmVyZ2Ftby5pdC9zZXJ2aXppL01lbnUvZGluYW1pY2EuYXNweD9pZFNlemlvbmU9Mzc4MCZhbXA7IzM4O2lkQXJlYT0xMTgyJmFtcDsjMzg7aWRDYXQ9NTU1JmFtcDsjMzg7SUQ9MjgzOTUmYW1wOyMzODtUaXBvRWxlbWVudG89Y2F0ZWdvcmlhIiB0YXJnZXQ9Il9ibGFuayImZ3Q7"/>Italian<ph id="mtc_3" equiv-text="base64:Jmx0Oy9hJmd0Ow=="/> <ph id="mtc_4" equiv-text="base64:Jmx0Oy9saSZndDs="/>##$_0A$##󠄀'; +// +// $l1_segment = $Filter->fromLayer0ToLayer1( $db_segment ); +// $l2_segment = $Filter->fromLayer1ToLayer2( $l1_segment ); +// +// $this->assertEquals($l1_segment, $expected_l1_segment); +// $this->assertEquals($l2_segment, $expected_l2_segment); +// +// $back_to_db_segment = $Filter->fromLayer1ToLayer0($l1_segment); +// +// $this->assertEquals($back_to_db_segment, $db_segment); +// +// } - $this->assertEquals($back_to_db_segment, $db_segment); - } +// public function testWithEncodedText() +// { +// $Filter = MateCatFilter::getInstance( new FeatureSet(), 'en-EN','et-ET', [] ); +// +// $db_segment = '<x id="3"/>Primary Care Facilities<x id="7"/>'; +// $expected_l1_segment = 'Primary Care Facilities'; +// $expected_l2_segment = '<ph id="mtc_1" equiv-text="base64:Jmx0O3ggaWQ9IjMiLyZndDs="/>Primary Care Facilities<ph id="mtc_2" equiv-text="base64:Jmx0O3ggaWQ9IjciLyZndDs="/>'; +// +// $l1_segment = $Filter->fromLayer0ToLayer1( $db_segment ); +// $l2_segment = $Filter->fromLayer1ToLayer2( $l1_segment ); +// +// $this->assertEquals($l1_segment, $expected_l1_segment); +// $this->assertEquals($l2_segment, $expected_l2_segment); +// +// $back_to_db_segment = $Filter->fromLayer1ToLayer0($l1_segment); +// +// $this->assertEquals($back_to_db_segment, $db_segment); +// } }