Skip to content

Commit e757c63

Browse files
committed
Settings: Add $form->protect + redirect to the same page is token is not valid
1 parent 5ed552c commit e757c63

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

main/admin/settings.lib.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ function handlePluginUpload()
159159
$form = new FormValidator(
160160
'plugin_upload',
161161
'post',
162-
'settings.php?category=Plugins#tabs-4'
162+
api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Plugins#tabs-4'
163163
);
164164
$form->addElement(
165165
'file',
@@ -397,8 +397,9 @@ function handleStylesheets()
397397
$form = new FormValidator(
398398
'stylesheet_upload',
399399
'post',
400-
'settings.php?category=Stylesheets#tabs-3'
400+
api_get_path().'admin/settings.php?category=Stylesheets#tabs-3'
401401
);
402+
$form->protect();
402403
$form->addElement(
403404
'text',
404405
'name_stylesheet',
@@ -1640,8 +1641,9 @@ function generateSettingsForm($settings, $settings_by_access_list)
16401641
$form = new FormValidator(
16411642
'settings',
16421643
'post',
1643-
'settings.php?category='.Security::remove_XSS($_GET['category'])
1644+
api_get_path(WEB_CODE_PATH).'admin/settings.php?category='.Security::remove_XSS($_GET['category'])
16441645
);
1646+
$form->protect();
16451647

16461648
$form->addElement(
16471649
'hidden',
@@ -1965,6 +1967,11 @@ function generateSettingsForm($settings, $settings_by_access_list)
19651967
}
19661968

19671969
switch ($row['variable']) {
1970+
case 'upload_extensions_replace_by':
1971+
$default_values[$row['variable']] = api_replace_dangerous_char(
1972+
str_replace('.', '', $default_values[$row['variable']])
1973+
);
1974+
break;
19681975
case 'pdf_export_watermark_enable':
19691976
$url = PDF::get_watermark(null);
19701977

main/inc/lib/pear/HTML/QuickForm.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,11 @@ public function validate()
14301430
$check = Security::check_token('form', $this);
14311431
Security::clear_token();
14321432
if (false === $check) {
1433+
// Redirect to the same URL + show token not validated message.
1434+
$url = $this->getAttribute('action');
1435+
Display::addFlash(Display::return_message(get_lang('NotValidated'), 'warning'));
1436+
api_location($url);
1437+
14331438
return false;
14341439
}
14351440
}

0 commit comments

Comments
 (0)