Commit 03cc01df authored by Falko Timme's avatar Falko Timme
Browse files

- Fixed FS#3320 - Improve php.ini parser.

parent c9262595
......@@ -126,4 +126,5 @@ $wb['added_date_txt'] = 'Hinzugefügt am';
$wb['backup_excludes_txt'] = 'Auszuschließende Verzeichnisse';
$wb['backup_excludes_note_txt'] = '(Mehrere Verzeichnisse mit Kommas trennen. Beispiel: web/cache/*,web/backup)';
$wb['backup_excludes_error_regex'] = 'Die auszuschließenden Verzeichnisse enthalten ungültige Zeichen.';
$wb['invalid_custom_php_ini_settings_txt'] = 'Unzulässige php.ini-Einstellungen';
?>
\ No newline at end of file
......@@ -126,4 +126,5 @@ $wb['added_date_txt'] = 'Added date';
$wb['backup_excludes_txt'] = 'Excluded Directories';
$wb['backup_excludes_note_txt'] = '(Separate multiple directories with commas. Example: web/cache/*,web/backup)';
$wb['backup_excludes_error_regex'] = 'The excluded directories contain invalid characters.';
$wb['invalid_custom_php_ini_settings_txt'] = 'Invalid php.ini settings';
?>
\ No newline at end of file
......@@ -726,6 +726,35 @@ class page_action extends tform_actions {
$app->tform->errorMessage .= $app->tform->lng("invalid_rewrite_rules_txt").'<br>';
}
}
// check custom php.ini settings
if(isset($this->dataRecord['custom_php_ini']) && trim($this->dataRecord['custom_php_ini']) != '') {
$custom_php_ini_settings = trim($this->dataRecord['custom_php_ini']);
$custom_php_ini_settings_are_valid = true;
// Make sure we only have Unix linebreaks
$custom_php_ini_settings = str_replace("\r\n", "\n", $custom_php_ini_settings);
$custom_php_ini_settings = str_replace("\r", "\n", $custom_php_ini_settings);
$custom_php_ini_settings_lines = explode("\n", $custom_php_ini_settings);
if(is_array($custom_php_ini_settings_lines) && !empty($custom_php_ini_settings_lines)){
foreach($custom_php_ini_settings_lines as $custom_php_ini_settings_line){
if(trim($custom_php_ini_settings_line) == '') continue;
if(substr(trim($custom_php_ini_settings_line),0,1) == ';') continue;
// empty value
if(preg_match('@^\s*;*\s*[a-zA-Z0-9._]*\s*=\s*;*\s*$@', $custom_php_ini_settings_line)) continue;
// value inside ""
if(preg_match('@^\s*;*\s*[a-zA-Z0-9._]*\s*=\s*".*"\s*;*\s*$@', $custom_php_ini_settings_line)) continue;
// value inside ''
if(preg_match('@^\s*;*\s*[a-zA-Z0-9._]*\s*=\s*\'.*\'\s*;*\s*$@', $custom_php_ini_settings_line)) continue;
// everything else
if(preg_match('@^\s*;*\s*[a-zA-Z0-9._]*\s*=\s*[-a-zA-Z0-9~&=_\@/,.#\s]*\s*;*\s*$@', $custom_php_ini_settings_line)) continue;
$custom_php_ini_settings_are_valid = false;
break;
}
}
if(!$custom_php_ini_settings_are_valid){
$app->tform->errorMessage .= $app->tform->lng("invalid_custom_php_ini_settings_txt").'<br>';
}
}
parent::onSubmit();
}
......
......@@ -2668,7 +2668,7 @@ class apache2_plugin {
if(substr($ini_setting, 0, 1) == ';') continue;
if(substr($ini_setting, 0, 1) == '#') continue;
if(substr($ini_setting, 0, 2) == '//') continue;
list($key, $value) = explode('=', $ini_setting);
list($key, $value) = explode('=', $ini_setting, 2);
if($value){
$value = trim($value);
$key = trim($key);
......
......@@ -2367,7 +2367,7 @@ class nginx_plugin {
if(substr($ini_setting, 0, 1) == ';') continue;
if(substr($ini_setting, 0, 1) == '#') continue;
if(substr($ini_setting, 0, 2) == '//') continue;
list($key, $value) = explode('=', $ini_setting);
list($key, $value) = explode('=', $ini_setting, 2);
if($value){
$value = trim($value);
$key = trim($key);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment