Skip to content
Extraits de code Groupes Projets
Valider 9c898084 rédigé par Stefan Giehl's avatar Stefan Giehl Validation de Matthieu Aubry
Parcourir les fichiers

Use mbstring proxy methods (#12104)

* Use mbstring proxy methods

* Avoid using strtolower/strtoupper if mbstring is not available to prevent possible unicode problems
parent da6e68b0
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -232,7 +232,27 @@ class Common
return mb_strtolower($string, 'UTF-8');
}
return strtolower($string);
// return unchanged string as using `strtolower` might cause unicode problems
return $string;
}
/**
* Multi-byte strtoupper() - works with UTF-8.
*
* Calls `mb_strtoupper` if available and falls back to `strtoupper` if not.
*
* @param string $string
* @return string
* @api
*/
public static function mb_strtoupper($string)
{
if (function_exists('mb_strtoupper')) {
return mb_strtoupper($string, 'UTF-8');
}
// return unchanged string as using `strtoupper` might cause unicode problems
return $string;
}
/*
......
......@@ -363,13 +363,14 @@ class ProcessedReport
list($newReport, $columns, $rowsMetadata, $totals) = $this->handleTableReport($idSite, $dataTable, $reportMetadata, $showRawMetrics, $formatMetrics);
if (function_exists('mb_substr')) {
if (function_exists('mb_substr')) {
foreach ($columns as &$name) {
if (substr($name, 0, 1) === mb_substr($name, 0, 1)) {
$name = ucfirst($name);
}
$name = ucfirst($name);
}
}
}
}
$website = new Site($idSite);
$period = Period\Factory::build($period, $date);
......
......@@ -9,6 +9,7 @@
namespace Piwik\Plugins\Intl\Commands;
use Piwik\Common;
use Piwik\Container\StaticContainer;
use Piwik\Development;
use Piwik\Filesystem;
......@@ -51,7 +52,7 @@ class GenerateIntl extends ConsoleCommand
}
preg_match_all("~^(.)(.*)$~u", $str, $arr);
return mb_strtoupper($arr[1][0], 'UTF-8').$arr[2][0];
return Common::mb_strtoupper($arr[1][0]).$arr[2][0];
}
protected function execute(InputInterface $input, OutputInterface $output)
......
......@@ -8,6 +8,7 @@
*/
namespace Piwik\Plugins\MobileMessaging;
use Piwik\Common;
use Piwik\Container\StaticContainer;
use Piwik\Plugin;
use Piwik\Piwik;
......@@ -213,7 +214,7 @@ abstract class SMSProvider
private static function sizeOfSMSContent($smsContent, $containsUCS2Chars)
{
if ($containsUCS2Chars) return mb_strlen($smsContent, 'UTF-8');
if ($containsUCS2Chars) return Common::mb_strlen($smsContent);
$sizeOfSMSContent = 0;
foreach (self::mb_str_split($smsContent) as $char) {
......
......@@ -8,6 +8,7 @@
*/
namespace Piwik\Plugins\ScheduledReports;
use Piwik\Common;
use Piwik\Date;
use Piwik\Piwik;
use Piwik\Plugins\LanguagesManager\LanguagesManager;
......@@ -36,7 +37,7 @@ class Controller extends \Piwik\Plugin\Controller
$reportTypes = API::getReportTypes();
$reportTypeOptions = array();
foreach ($reportTypes as $reportType => $icon) {
$reportTypeOptions[$reportType] = mb_strtoupper($reportType);
$reportTypeOptions[$reportType] = Common::mb_strtoupper($reportType);
}
$view->reportTypes = $reportTypes;
$view->reportTypeOptions = $reportTypeOptions;
......@@ -53,7 +54,7 @@ class Controller extends \Piwik\Plugin\Controller
$reportFormatsByReportType[$reportType] = API::getReportFormats($reportType);
$reportFormatsByReportTypeOptions[$reportType] = $reportFormatsByReportType[$reportType];
foreach ($reportFormatsByReportTypeOptions[$reportType] as $type => $icon) {
$reportFormatsByReportTypeOptions[$reportType][$type] = mb_strtoupper($type);
$reportFormatsByReportTypeOptions[$reportType][$type] = Common::mb_strtoupper($type);
}
$allowMultipleReportsByReportType[$reportType] = API::allowMultipleReports($reportType);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter