/** * Checks if query parameters are of a non-UTF-8 encoding and converts the values * from the specified encoding to UTF-8. * This method is used to workaround browser/webapp bugs (see #3450). When * browsers fail to encode query parameters in UTF-8, the tracker will send the * charset of the page viewed and we can sometimes work around invalid data * being stored. * * @param array $queryParameters Name/value mapping of query parameters. * @param bool|string $encoding of the HTML page the URL is for. Used to workaround * browser bugs & mis-coded webapps. See #3450. * * @return array */ public static function reencodeParameters(&$queryParameters, $encoding = false) { 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 (strtolower($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; }