Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Translate/Writer.php21
1 files changed, 7 insertions, 14 deletions
diff --git a/core/Translate/Writer.php b/core/Translate/Writer.php
index a1b295fa07..66e34449ec 100644
--- a/core/Translate/Writer.php
+++ b/core/Translate/Writer.php
@@ -99,10 +99,16 @@ class Writer
/**
* @param string $language ISO 639-1 alpha-2 language code
+ *
+ * @throws \Exception
*/
public function setLanguage($language)
{
- $this->_language = $language;
+ if (!preg_match('/^([a-z]{2,3}(-[a-z]{2,3})?)$/i', $language)) {
+ throw new Exception(Piwik_TranslateException('General_ExceptionLanguageFileNotFound', array($language)));
+ }
+
+ $this->_language = strtolower($language);
}
/**
@@ -185,21 +191,8 @@ class Writer
{
if (empty($lang)) $lang = $this->getLanguage();
- if (!Common::isValidFilename($lang) ||
- ($base !== 'lang' && $base !== 'tmp')
- ) {
- throw new Exception(Piwik_TranslateException('General_ExceptionLanguageFileNotFound', array($lang)));
- }
-
if (!empty($this->_pluginName)) {
- $installedPlugins = PluginsManager::getInstance()->readPluginsDirectory();
-
- if (!in_array($this->_pluginName, $installedPlugins)) {
-
- throw new Exception(Piwik_TranslateException('General_ExceptionLanguageFileNotFound', array($lang)));
- }
-
if ($base == 'tmp') {
return sprintf('%s/tmp/plugins/%s/lang/%s.json', PIWIK_INCLUDE_PATH, $this->_pluginName, $lang);
} else {