Skip to content

Commit 6e09461

Browse files
author
Till Brehm
committed
Fixed #5102
1 parent e41a487 commit 6e09461

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+72
-51
lines changed

interface/lib/classes/functions.inc.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,28 @@ public function htmlentities($value) {
477477

478478
return $out;
479479
}
480+
481+
// Function to check paths before we use it as include. Use with absolute paths only.
482+
public function check_include_path($path) {
483+
if(strpos($path,'//')) die('Include path seems to be an URL: '.$this->htmlentities($path));
484+
if(strpos($path,'..')) die('Two dots are not allowed in include path: '.$this->htmlentities($path));
485+
if(!preg_match("/^[a-zA-Z0-9_\/\.\-]{1,}$/", $path)) die('Wrong chars in include path: '.$this->htmlentities($path));
486+
$path = realpath($path);
487+
if($path == '') die('Include path does not exist.');
488+
if(substr($path,0,strlen(ISPC_ROOT_PATH)) != ISPC_ROOT_PATH) die('Path '.$this->htmlentities($path).' is outside of ISPConfig installation directory.');
489+
return $path;
490+
}
491+
492+
// Function to check language strings
493+
public function check_language($language) {
494+
global $app;
495+
if(preg_match('/^[a-z]{2}$/',$language)) {
496+
return $language;
497+
} else {
498+
die('Invalid language string: '.$this->htmlentities($language));
499+
}
500+
}
501+
480502
}
481503

482504
?>

interface/lib/classes/listform.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function loadListDef($file, $module = '')
6060
}
6161

6262
//* Set local Language File
63-
$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_'.$this->listDef['name'].'_list.lng';
63+
$lng_file = 'lib/lang/'.$app->functions->check_language($_SESSION['s']['language']).'_'.$this->listDef['name'].'_list.lng';
6464
if(!file_exists($lng_file)) $lng_file = 'lib/lang/en_'.$this->listDef['name'].'_list.lng';
6565
include $lng_file;
6666

interface/lib/classes/listform_actions.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public function onShow()
249249
global $app;
250250

251251
//* Set global Language File
252-
$lng_file = ISPC_LIB_PATH.'/lang/'.$_SESSION['s']['language'].'.lng';
252+
$lng_file = ISPC_LIB_PATH.'/lang/'.$app->functions->check_language($_SESSION['s']['language']).'.lng';
253253
if(!file_exists($lng_file))
254254
$lng_file = ISPC_LIB_PATH.'/lang/en.lng';
255255
include $lng_file;

interface/lib/classes/listform_tpl_generator.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ function buildHTML($listDef, $module = '') {
153153
}
154154

155155
function lng_add($lang, $listDef, $module = '') {
156-
global $go_api, $go_info, $conf;
156+
global $app, $conf;
157157

158158
if($module == '') {
159-
$lng_file = "lib/lang/".$conf["language"]."_".$listDef['name']."_list.lng";
159+
$lng_file = "lib/lang/".$app->functions->check_language($conf["language"])."_".$listDef['name']."_list.lng";
160160
} else {
161161
$lng_file = '../'.$module."/lib/lang/en_".$listDef['name']."_list.lng";
162162
}

interface/lib/classes/plugin_backuplist.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function onShow() {
4545
$listTpl->newTemplate('templates/web_backup_list.htm');
4646

4747
//* Loading language file
48-
$lng_file = "lib/lang/".$_SESSION["s"]["language"]."_web_backup_list.lng";
48+
$lng_file = "lib/lang/".$app->functions->check_language($_SESSION["s"]["language"])."_web_backup_list.lng";
4949
include $lng_file;
5050
$listTpl->setVar($wb);
5151

interface/lib/classes/plugin_backuplist_mail.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function onShow() {
4646
$listTpl->newTemplate('templates/mail_user_backup_list.htm');
4747

4848
//* Loading language file
49-
$lng_file = "lib/lang/".$_SESSION["s"]["language"]."_mail_backup_list.lng";
49+
$lng_file = "lib/lang/".$app->functions->check_language($_SESSION["s"]["language"])."_mail_backup_list.lng";
5050
include($lng_file);
5151
$listTpl->setVar($wb);
5252

interface/lib/classes/plugin_directive_snippets.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function onShow()
1818
$listTpl->newTemplate('templates/web_directive_snippets.htm');
1919

2020
//* Loading language file
21-
$lng_file = "lib/lang/".$_SESSION["s"]["language"]."_web_directive_snippets.lng";
21+
$lng_file = "lib/lang/".$app->functions->check_language($_SESSION["s"]["language"])."_web_directive_snippets.lng";
2222

2323
include $lng_file;
2424
$listTpl->setVar($wb);

interface/lib/classes/plugin_listview.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function onShow() {
120120
}
121121

122122
// Loading language field
123-
$lng_file = "lib/lang/".$_SESSION["s"]["language"]."_".$app->listform->listDef['name']."_list.lng";
123+
$lng_file = "lib/lang/".$app->functions->check_language($_SESSION["s"]["language"])."_".$app->listform->listDef['name']."_list.lng";
124124
include $lng_file;
125125
$listTpl->setVar($wb);
126126

interface/lib/classes/searchform_actions.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ function onShow() {
151151
global $app;
152152

153153
// Language File setzen
154-
$lng_file = ISPC_WEB_PATH.'/lang/lib/lang/'.$_SESSION['s']['language'].'_list.lng';
154+
$lng_file = ISPC_WEB_PATH.'/lang/lib/lang/'.$app->functions->check_language($_SESSION['s']['language']).'_list.lng';
155155
if(!file_exists($lng_file)) $lng_file = ISPC_WEB_PATH.'/lang/lib/lang/en_'.'_list.lng';
156156
include $lng_file;
157-
$lng_file = "lib/lang/".$_SESSION["s"]["language"]."_".$app->searchform->listDef['name']."_search.lng";
157+
$lng_file = "lib/lang/".$app->functions->check_language($_SESSION["s"]["language"])."_".$app->searchform->listDef['name']."_search.lng";
158158
if(!file_exists($lng_file)) $lng_file = 'lib/lang/en_'.$app->searchform->listDef['name']."_search.lng";
159159
include $lng_file;
160160
$app->tpl->setVar($wb);

interface/lib/classes/tform_base.inc.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function loadFormDef($file, $module = '') {
134134
$this->module = $module;
135135
$wb = array();
136136

137-
include_once ISPC_ROOT_PATH.'/lib/lang/'.$_SESSION['s']['language'].'.lng';
137+
include_once ISPC_ROOT_PATH.'/lib/lang/'.$app->functions->check_language($_SESSION['s']['language']).'.lng';
138138

139139
if(is_array($wb)) $wb_global = $wb;
140140

@@ -143,7 +143,7 @@ function loadFormDef($file, $module = '') {
143143
if(!file_exists($lng_file)) $lng_file = "lib/lang/en_".$this->formDef["name"].".lng";
144144
include $lng_file;
145145
} else {
146-
$lng_file = "../$module/lib/lang/".$_SESSION["s"]["language"]."_".$this->formDef["name"].".lng";
146+
$lng_file = "../$module/lib/lang/".$app->functions->check_language($_SESSION["s"]["language"])."_".$this->formDef["name"].".lng";
147147
if(!file_exists($lng_file)) $lng_file = "../$module/lib/lang/en_".$this->formDef["name"].".lng";
148148
include $lng_file;
149149
}

0 commit comments

Comments
 (0)