From 5ba38f4fa11a1b33f075acc7ebaa23f92f1e6343 Mon Sep 17 00:00:00 2001
From: mattab <matthieu.aubry@gmail.com>
Date: Sun, 12 May 2013 22:00:46 +1200
Subject: [PATCH] Fixing a bug with row evolution label containing commas

---
 plugins/API/API.php                            |  2 --
 tests/PHPUnit/Integration/RowEvolutionTest.php | 14 +++++++-------
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/plugins/API/API.php b/plugins/API/API.php
index 7346cff996..f417dcaf52 100644
--- a/plugins/API/API.php
+++ b/plugins/API/API.php
@@ -1162,11 +1162,9 @@ class Piwik_API_API
         }
 
         $label = Piwik_API_ResponseBuilder::unsanitizeLabelParameter($label);
-        $label = urldecode($label);
         if ($label) {
             $labels = explode(',', $label);
             $labels = array_unique($labels);
-//            $labels = array_map('urldecode', $labels);
         } else {
             $labels = array();
         }
diff --git a/tests/PHPUnit/Integration/RowEvolutionTest.php b/tests/PHPUnit/Integration/RowEvolutionTest.php
index d7aa38b7bd..90266e842d 100755
--- a/tests/PHPUnit/Integration/RowEvolutionTest.php
+++ b/tests/PHPUnit/Integration/RowEvolutionTest.php
@@ -51,20 +51,20 @@ class Test_Piwik_Integration_RowEvolution extends IntegrationTestCase
         // Websites, hierarchical
         $config['testSuffix'] = '_referrer2';
         $referrerLabel = urlencode('www.referrer0.com') . '>' . urlencode('theReferrerPage1.html');
-        $config['otherRequestParameters']['label'] = urlencode($referrerLabel);
+        $config['otherRequestParameters']['label'] = ($referrerLabel);
         $return[] = array('API.getRowEvolution', $config);
 
         // Websites, multiple labels including one hierarchical
         $config['testSuffix'] = '_referrerMulti1';
         $referrerLabel = $referrerLabel . ',' . urlencode('www.referrer2.com');
-        $config['otherRequestParameters']['label'] = urlencode($referrerLabel);
+        $config['otherRequestParameters']['label'] = ($referrerLabel);
         $return[] = array('API.getRowEvolution', $config);
 
         // Keywords, label containing > and ,
         $config['otherRequestParameters']['apiAction'] = 'getKeywords';
         $config['testSuffix'] = '_LabelReservedCharacters';
         $keywordsStr = urlencode($keywords[0]) . ',' . urlencode($keywords[1]);
-        $config['otherRequestParameters']['label'] = urlencode($keywordsStr);
+        $config['otherRequestParameters']['label'] = ($keywordsStr);
         $return[] = array('API.getRowEvolution', $config);
 
         // Keywords, hierarchical
@@ -74,7 +74,7 @@ class Test_Piwik_Integration_RowEvolution extends IntegrationTestCase
             . ',Google>' . urlencode(strtolower($keywords[1]))
             . ',Google>' . urlencode(strtolower($keywords[2]));
         // Test multiple labels search engines, Google should also have a 'logo' entry
-        $config['otherRequestParameters']['label'] = urlencode($keywordsStr . ",Google");
+        $config['otherRequestParameters']['label'] = ($keywordsStr . ",Google");
         $config['otherRequestParameters']['filter_limit'] = 1; // should have no effect
         $return[] = array('API.getRowEvolution', $config);
 
@@ -90,7 +90,7 @@ class Test_Piwik_Integration_RowEvolution extends IntegrationTestCase
         // Actions > Page titles, multiple labels
         $config['testSuffix'] = '_pageTitlesMulti';
         $label = urlencode('incredible title 0') . ',' . urlencode('incredible title 2');
-        $config['otherRequestParameters']['label'] = urlencode($label);
+        $config['otherRequestParameters']['label'] = ($label);
         $return[] = array('API.getRowEvolution', $config);
         
         // standard label, entry page titles
@@ -107,7 +107,7 @@ class Test_Piwik_Integration_RowEvolution extends IntegrationTestCase
         $config['otherRequestParameters']['date'] = '2010-03-01,2010-03-06';
         $config['otherRequestParameters']['apiModule'] = 'Actions';
         $config['otherRequestParameters']['apiAction'] = 'getPageUrls';
-        $config['otherRequestParameters']['label'] = urlencode('my>dir>' . urlencode('/page3?foo=bar&baz=bar'));
+        $config['otherRequestParameters']['label'] = ('my>dir>' . urlencode('/page3?foo=bar&baz=bar'));
         $return[] = array('API.getRowEvolution', $config);
 
         // Goals > Visits Until Conversion, idGoal != 0
@@ -117,7 +117,7 @@ class Test_Piwik_Integration_RowEvolution extends IntegrationTestCase
         $config['otherRequestParameters']['period'] = 'day';
         $config['otherRequestParameters']['apiModule'] = 'Goals';
         $config['otherRequestParameters']['apiAction'] = 'getVisitsUntilConversion';
-        $config['otherRequestParameters']['label'] = urlencode('1 visit, 2 visits');
+        $config['otherRequestParameters']['label'] = ('1 visit, 2 visits');
         $config['otherRequestParameters']['idGoal'] = '2';
         $return[] = array('API.getRowEvolution', $config);
 
-- 
GitLab