Skip to content
Permalink
Browse files Browse the repository at this point in the history
detaint language file.
  • Loading branch information
Isaac Connor committed Feb 8, 2022
1 parent 2db781e commit 9fee64b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions web/includes/lang.php
Expand Up @@ -30,20 +30,21 @@ function translate($name) {
function loadLanguage($prefix='') {
global $user;

if ( $prefix )
if ($prefix)
$prefix = $prefix.'/';

if ( isset($user['Language']) and $user['Language'] ) {
$userLangFile = $prefix.'lang/'.$user['Language'].'.php';
if (isset($user['Language']) and $user['Language']) {
# Languages can only have letters, numbers and underscore
$userLangFile = $prefix.'lang/'.preg_replace('/[^[:alnum:]_]+/', '', $user['Language']).'.php';

if ( file_exists($userLangFile) ) {
if (file_exists($userLangFile)) {
return $userLangFile;
} else {
ZM\Warning("User language file $userLangFile does not exist.");
}
}

$systemLangFile = $prefix.'lang/'.ZM_LANG_DEFAULT.'.php';
$systemLangFile = $prefix.'lang/'.preg_replace('/[^[:alnum:]_]+/', '', ZM_LANG_DEFAULT).'.php';
if ( file_exists($systemLangFile) ) {
return $systemLangFile;
} else {
Expand Down

0 comments on commit 9fee64b

Please sign in to comment.