Skip to content

Commit

Permalink
Added a workaround for situations where the subject or email body is …
Browse files Browse the repository at this point in the history
…too big for MantisBT standards
  • Loading branch information
SL-Gundam committed Jun 17, 2014
1 parent bd81f8e commit 83698d2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
38 changes: 37 additions & 1 deletion core/mail_api.php
Expand Up @@ -82,6 +82,8 @@ class ERP_mailbox_api
private $_use_ldap_email;

private $_max_file_size;
private $_max_text_len = 65535; // mysql text datatype
private $_max_subject_len = 128; // mysql varchar(128) datatype
private $_memory_limit;

# --------------------
Expand Down Expand Up @@ -736,6 +738,7 @@ private function add_bug( &$p_email, $p_overwrite_project_id = FALSE )

$t_description = $this->identify_replies( $t_description );
$t_description = $this->strip_signature( $t_description );
check_field_lengths( 'note', $p_email, $t_description );
$t_description = $this->add_additional_info( 'note', $p_email, $t_description );

$t_project_id = bug_get_field( $t_bug_id, 'project_id' );
Expand Down Expand Up @@ -786,11 +789,14 @@ private function add_bug( &$p_email, $p_overwrite_project_id = FALSE )
$t_bug_data->eta = (int) config_get( 'default_bug_eta' );
$t_bug_data->resolution = config_get( 'default_bug_resolution' );
$t_bug_data->status = config_get( 'bug_submit_status' );
$t_bug_data->summary = $p_email[ 'Subject' ];

$t_description = $p_email[ 'X-Mantis-Body' ];
$t_description = $this->strip_signature( $t_description );
check_field_lengths( 'issue', $p_email, $t_description );
$t_description = $this->add_additional_info( 'issue', $p_email, $t_description );

$t_bug_data->summary = $p_email[ 'Subject' ];

$t_bug_data->description = $t_description;

$t_bug_data->steps_to_reproduce = config_get( 'default_bug_steps_to_reproduce' );
Expand Down Expand Up @@ -1373,6 +1379,36 @@ private function strip_signature( $p_description )
return( $t_description );
}

# --------------------
# Check the subject and email body to see if they are too long for MantisBT database fields
private function check_field_lengths( $p_type, &$p_email, &$p_description )
{
if ( strlen( $p_email[ 'Subject' ] ) > $this->_max_subject_len )
{
$p_email[ 'Subject' ] = substr( $p_email[ 'Subject' ], 0, $this->_max_subject_len );
}

if ( strlen( $p_description ) > $this->_max_text_len )
{
if ( $this->_allow_file_upload )
{
$t_part = array(
'name' => $p_type . '_description.txt',
'ctype' => 'text/plain',
'body' => $p_description,
);

$p_description = 'Email body was too big. It has been moved to the attachments';

array_push( $p_email[ 'X-Mantis-Parts' ], $t_part );
}
else
{
$p_description = substr( $p_description, 0, $this->_max_text_len );
}
}
}

# --------------------
# Show memory usage in debug mode
private function show_memory_usage( $p_location )
Expand Down
1 change: 1 addition & 0 deletions doc/CHANGELOG.bug_report_mail.txt
Expand Up @@ -87,6 +87,7 @@ Nov 2013 - EmailReporting-0.9.0-DEV
- Attachment blocking added based on a md5 hash list
- Added feature to remove Gmail style replies in notes
- Added feature to add users from Cc and To list of mail header to issue monitoring list
- Added a workaround for situations where the subject or email body is too big for MantisBT standards

Nov 2010 - EmailReporting-0.8.4
- Improved the project category list
Expand Down

0 comments on commit 83698d2

Please sign in to comment.