diff --git a/core/Tracker/PageUrl.php b/core/Tracker/PageUrl.php index ae55b48aac3169e8abd3bb72e9131fdfe2e45831..e629ef55bfcc91a60f75b46c382746f5900ad770 100644 --- a/core/Tracker/PageUrl.php +++ b/core/Tracker/PageUrl.php @@ -256,13 +256,18 @@ class PageUrl */ public static function reencodeParameters(&$queryParameters, $encoding = false) { - // if query params are encoded w/ non-utf8 characters (due to browser bug or whatever), - // encode to UTF-8. - if (false !== $encoding - && 'utf-8' != strtolower($encoding) - && function_exists('mb_check_encoding') - ) { - $queryParameters = PageUrl::reencodeParametersArray($queryParameters, $encoding); + if (function_exists('mb_check_encoding')) { + // if query params are encoded w/ non-utf8 characters (due to browser bug or whatever), + // encode to UTF-8. + if ($encoding != 'utf-8' + && $encoding != false + ) { + Common::printDebug("Encoding page URL query parameters to $encoding."); + + $queryParameters = PageUrl::reencodeParametersArray($queryParameters, $encoding); + } + } else { + Common::printDebug("Page charset supplied in tracking request, but mbstring extension is not available."); } return $queryParameters; @@ -349,5 +354,15 @@ class PageUrl return array(); } -} + public static function urldecodeValidUtf8($value) + { + $value = urldecode($value); + if (function_exists('mb_check_encoding') + && !@mb_check_encoding($value, 'utf-8') + ) { + return urlencode($value); + } + return $value; + } +} \ No newline at end of file diff --git a/plugins/Actions/Actions/ActionSiteSearch.php b/plugins/Actions/Actions/ActionSiteSearch.php index d19cfaa6fc71ac0942b926ed2e25c803d017e1ba..392e3777f8dc4a15675c9d74d0baac89125add9c 100644 --- a/plugins/Actions/Actions/ActionSiteSearch.php +++ b/plugins/Actions/Actions/ActionSiteSearch.php @@ -180,14 +180,19 @@ class ActionSiteSearch extends Action if (is_array($actionName)) { $actionName = reset($actionName); } - $actionName = trim(urldecode($actionName)); + + $actionName = PageUrl::urldecodeValidUtf8($actionName); + $actionName = trim($actionName); if (empty($actionName)) { return false; } + if (is_array($categoryName)) { $categoryName = reset($categoryName); } - $categoryName = trim(urldecode($categoryName)); + $categoryName = PageUrl::urldecodeValidUtf8($categoryName); + $categoryName = trim($categoryName); + return array($url, $actionName, $categoryName, $count); } diff --git a/plugins/TestRunner/templates/travis.yml.twig b/plugins/TestRunner/templates/travis.yml.twig index 1972feb6c82eea7b6ba3e42dcf2dc76e47e6acef..c7faa74372508f64ee1cfd7525bf5bb893a2488b 100644 --- a/plugins/TestRunner/templates/travis.yml.twig +++ b/plugins/TestRunner/templates/travis.yml.twig @@ -146,8 +146,6 @@ before_script: # configure mysql - mysql -e "SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES'" # Travis default - # Uncomment to enable sql_mode STRICT_TRANS_TABLES (new default in Mysql 5.6) - - mysql -e "SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION'" - mysql -e "SELECT @@sql_mode;" - mysql -e "SHOW GLOBAL VARIABLES;" {% if pluginName is empty %} diff --git a/tests/PHPUnit/System/PrivacyManagerTest.php b/tests/PHPUnit/System/PrivacyManagerTest.php index 18b197a4102eb215279cd01ad4d5110f8a86f57e..0d99d0816d3eded22b790ff012469961dfb08c32 100644 --- a/tests/PHPUnit/System/PrivacyManagerTest.php +++ b/tests/PHPUnit/System/PrivacyManagerTest.php @@ -374,7 +374,7 @@ class PrivacyManagerTest extends SystemTestCase // perform checks $this->checkLogDataPurged(); - $this->_checkReportsAndMetricsPurged($janBlobsRemaining = 5, $janNumericRemaining = 68); // 5 blobs for 5 days + $this->_checkReportsAndMetricsPurged($janBlobsRemaining = 5, $janNumericRemaining = 69); // 5 blobs for 5 days } /** @@ -574,7 +574,7 @@ class PrivacyManagerTest extends SystemTestCase // perform checks $this->checkLogDataPurged(); - $this->_checkReportsAndMetricsPurged($janBlobsRemaining = 6, $janNumericRemaining = 70); // 1 segmented blob + 5 day blobs + $this->_checkReportsAndMetricsPurged($janBlobsRemaining = 6, $janNumericRemaining = 71); // 1 segmented blob + 5 day blobs } // --- utility functions follow --- @@ -720,15 +720,15 @@ class PrivacyManagerTest extends SystemTestCase // one metric for jan & one for feb Db::query(sprintf($sql, Common::prefixTable($archiveTables['numeric'][0])), - array(self::GARBAGE_FIELD, $janDate1, $janDate1, $janDate1, 1, 100)); + array(self::GARBAGE_FIELD, $janDate1, $janDate1, 1, $janDate1, 100)); Db::query(sprintf($sql, Common::prefixTable($archiveTables['numeric'][1])), - array(self::GARBAGE_FIELD, $febDate1, $febDate1, $febDate1, 1, 200)); + array(self::GARBAGE_FIELD, $febDate1, $febDate1, 1, $febDate1, 200)); // add garbage reports Db::query(sprintf($sql, Common::prefixTable($archiveTables['blob'][0])), - array(self::GARBAGE_FIELD, $janDate1, $janDate1, $janDate1, 10, 'blobval')); + array(self::GARBAGE_FIELD, $janDate1, $janDate1, 10, $janDate1, 'blobval')); Db::query(sprintf($sql, Common::prefixTable($archiveTables['blob'][1])), - array(self::GARBAGE_FIELD, $febDate1, $febDate1, $febDate1, 20, 'blobval')); + array(self::GARBAGE_FIELD, $febDate1, $febDate1, 20, $febDate1, 'blobval')); } protected function _checkNoDataChanges()