mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 13:28:55 +00:00
[ticket/security/244] Add form token check to plupload
SECURTIY-244
This commit is contained in:
parent
525c940385
commit
56477a8f7c
4 changed files with 52 additions and 2 deletions
|
@ -90,6 +90,12 @@ phpbb.plupload.getSerializedData = function() {
|
||||||
obj['attachment_data[' + i + '][' + key + ']'] = datum[key];
|
obj['attachment_data[' + i + '][' + key + ']'] = datum[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Insert form data
|
||||||
|
var $pluploadForm = $(phpbb.plupload.config.form_hook).first();
|
||||||
|
obj.creation_time = $pluploadForm.find('input[type=hidden][name="creation_time"]').val();
|
||||||
|
obj.form_token = $pluploadForm.find('input[type=hidden][name="form_token"]').val();
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -264,6 +270,17 @@ phpbb.plupload.deleteFile = function(row, attachId) {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle errors while deleting file
|
||||||
|
if (typeof response.error !== 'undefined') {
|
||||||
|
phpbb.alert(phpbb.plupload.lang.ERROR, response.error.message);
|
||||||
|
|
||||||
|
// We will have to assume that the deletion failed. So leave the file status as uploaded.
|
||||||
|
row.find('.file-status').toggleClass('file-uploaded');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
phpbb.plupload.update(response, 'removal', index);
|
phpbb.plupload.update(response, 'removal', index);
|
||||||
// Check if the user can upload files now if he had reached the max files limit.
|
// Check if the user can upload files now if he had reached the max files limit.
|
||||||
phpbb.plupload.handleMaxFilesReached();
|
phpbb.plupload.handleMaxFilesReached();
|
||||||
|
|
|
@ -1524,6 +1524,35 @@ class parse_message extends bbcode_firstpass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check attachment form token depending on submit type
|
||||||
|
*
|
||||||
|
* @param \phpbb\language\language $language Language
|
||||||
|
* @param \phpbb\request\request_interface $request Request
|
||||||
|
* @param string $form_name Form name for checking form key
|
||||||
|
*
|
||||||
|
* @return bool True if form token is not needed or valid, false if needed and invalid
|
||||||
|
*/
|
||||||
|
function check_attachment_form_token(\phpbb\language\language $language, \phpbb\request\request_interface $request, $form_name)
|
||||||
|
{
|
||||||
|
$add_file = $request->is_set_post('add_file');
|
||||||
|
$delete_file = $request->is_set_post('delete_file');
|
||||||
|
|
||||||
|
if (($add_file || $delete_file) && !check_form_key($form_name))
|
||||||
|
{
|
||||||
|
$this->warn_msg[] = $language->lang('FORM_INVALID');
|
||||||
|
|
||||||
|
if ($request->is_ajax() && $this->plupload)
|
||||||
|
{
|
||||||
|
$this->plupload->emit_error(-400, 'FORM_INVALID');
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse Attachments
|
* Parse Attachments
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -26,7 +26,7 @@ if (!defined('IN_PHPBB'))
|
||||||
function compose_pm($id, $mode, $action, $user_folders = array())
|
function compose_pm($id, $mode, $action, $user_folders = array())
|
||||||
{
|
{
|
||||||
global $template, $db, $auth, $user, $cache;
|
global $template, $db, $auth, $user, $cache;
|
||||||
global $phpbb_root_path, $phpEx, $config;
|
global $phpbb_root_path, $phpEx, $config, $language;
|
||||||
global $request, $phpbb_dispatcher, $phpbb_container;
|
global $request, $phpbb_dispatcher, $phpbb_container;
|
||||||
|
|
||||||
// Damn php and globals - i know, this is horrible
|
// Damn php and globals - i know, this is horrible
|
||||||
|
@ -799,7 +799,10 @@ function compose_pm($id, $mode, $action, $user_folders = array())
|
||||||
extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_modify_parse_before', compact($vars)));
|
extract($phpbb_dispatcher->trigger_event('core.ucp_pm_compose_modify_parse_before', compact($vars)));
|
||||||
|
|
||||||
// Parse Attachments - before checksum is calculated
|
// Parse Attachments - before checksum is calculated
|
||||||
$message_parser->parse_attachments('fileupload', $action, 0, $submit, $preview, $refresh, true);
|
if ($message_parser->check_attachment_form_token($language, $request, 'ucp_pm_compose'))
|
||||||
|
{
|
||||||
|
$message_parser->parse_attachments('fileupload', $action, 0, $submit, $preview, $refresh, true);
|
||||||
|
}
|
||||||
|
|
||||||
if (count($message_parser->warn_msg) && !($remove_u || $remove_g || $add_to || $add_bcc))
|
if (count($message_parser->warn_msg) && !($remove_u || $remove_g || $add_to || $add_bcc))
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,6 +57,7 @@ phpbb.plupload = {
|
||||||
lang: {
|
lang: {
|
||||||
ERROR: '{LA_ERROR}',
|
ERROR: '{LA_ERROR}',
|
||||||
TOO_MANY_ATTACHMENTS: '{LA_TOO_MANY_ATTACHMENTS}',
|
TOO_MANY_ATTACHMENTS: '{LA_TOO_MANY_ATTACHMENTS}',
|
||||||
|
FORM_INVALID: '{LA_FORM_INVALID}',
|
||||||
},
|
},
|
||||||
order: '{ATTACH_ORDER}',
|
order: '{ATTACH_ORDER}',
|
||||||
maxFiles: {MAX_ATTACHMENTS},
|
maxFiles: {MAX_ATTACHMENTS},
|
||||||
|
|
Loading…
Add table
Reference in a new issue