Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: fd20db77b26a
Choose a base ref
...
head repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 83fb71b5dc9b
Choose a head ref
  • 5 commits
  • 25 files changed
  • 1 contributor

Commits on Aug 16, 2012

  1. Store bugnote URL replacement string in a static variable

    The purpose is to make code more readable.
    
    Follow up on fix for issue #14447.
    dregad committed Aug 16, 2012
    Copy the full SHA
    19b2865 View commit details

Commits on Aug 17, 2012

  1. Upgrade PHPMailer from 5.1 to 5.2.1

    Version 5.2.1 (January 16, 2012)
    * Closed several bugs
    * Performance improvements
    * MsgHTML() now returns the message as required.
    * New method: GetSentMIMEMessage() (returns full copy of sent message)
    
    Version 5.2 (July 19, 2011)
    * protected MIME body and header
    * better DKIM DNS Resource Record support
    * better aly handling
    * htmlfilter class added to extras
    * moved to Apache Extras
    
    Fixes #12562
    dregad committed Aug 17, 2012
    Copy the full SHA
    8c81d4c View commit details
  2. Fix #14630: Improved logging for emails

    Prior to this, several e-mail related events were not reported at all,
    making troubleshooting of issues difficult. The following cases are now
    logged:
    
     * sending of queued messages (email_send_all)
     * errors thrown by PHPMailer
     * reminder emails (email_bug_reminder) - fixes #9368
     * deletion of records from the email queue
    
    In addition, admin/email_queue.php was modified to print a formatted
    date instead of a numeric timestamp.
    dregad committed Aug 17, 2012
    Copy the full SHA
    4ff0a95 View commit details
  3. Fix #14631: Consistent email validation

    PHPMailer uses filter_var() to check for an e-mail validity; this
    function treats single-domain e-mail addresses (e.g. user@localhost) as
    invalid. However, Mantis API function email_is_valid() relies on a
    custom regex to validate e-mails, which does accept such addresses. As a
    consequence, we accept addresses to which we are unable to send
    messages.
    
    To avoid this problem, we now rely on PHPMailer::ValidateAddress()
    method to ensure that any email we store can be sent PHPMailer.
    dregad committed Aug 17, 2012
    Copy the full SHA
    6987b4a View commit details
  4. Do not skip e-mail validation if $g_login_method != LDAP

    Prior to this, function email_is_valid() always returned true when
    $g_use_ldap_email = ON, even if $g_login_method != LDAP.
    
    Even though this is not an usual case (when not using LDAP, the other
    LDAP-related configuration options should be left to their default
    values), this causes the actual validation to be skipped which could
    lead to email sending errors.
    
    Fixes #14632
    dregad committed Aug 17, 2012
    Copy the full SHA
    83fb71b View commit details
9 changes: 7 additions & 2 deletions admin/email_queue.php
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@
echo "Sending or deleting emails...<br />";
email_send_all(true);
echo "Done";

} else {
$t_email_data = email_queue_get( (int) $f_to );

@@ -65,7 +65,12 @@
foreach( $t_ids as $t_id ) {
$row = email_queue_get( $t_id );

echo '<tr><td>' . $row->email_id . '</td><td>' . $row->email . '</td><td>' . $row->submitted . '</td><td>' , html_button( 'email_queue.php', 'Send Or Delete', array( 'send' => $row->email_id ) ) , '</td></tr>';
echo '<tr><td>'
. $row->email_id . '</td><td>'
. $row->email . '</td><td>'
. date( config_get( 'complete_date_format' ), $row->submitted ) . '</td><td>'
, html_button( 'email_queue.php', 'Send Or Delete', array( 'send' => $row->email_id ) )
, '</td></tr>';
}
echo '</table>';
} else {
60 changes: 29 additions & 31 deletions core/email_api.php
Original file line number Diff line number Diff line change
@@ -50,6 +50,10 @@
* requires relationship_api
*/
require_once( 'relationship_api.php' );
/**
* requires PHPMailer library
*/
require_once( 'phpmailer' . DIRECTORY_SEPARATOR . 'class.phpmailer.php' );

/**
* reusable object of class SMTP
@@ -88,19 +92,17 @@ function email_is_valid( $p_email ) {
return true;
}

if ( ON == config_get( 'use_ldap_email' ) ) {
if ( LDAP == config_get( 'login_method' ) && ON == config_get( 'use_ldap_email' ) ) {
return true;
}

if( is_blank( $p_email ) && ON == config_get( 'allow_blank_email' ) ) {
return true;
}

# Use a regular expression to check to see if the email is in valid format
# x-xx.xxx@yyy.zzz.abc etc.
if( preg_match( email_regex_simple(), $p_email, $t_check ) ) {
$t_local = $t_check[1];
$t_domain = $t_check[2];
# Delegate email validation to PHPMailer
if( PHPMailer::ValidateAddress( $p_email ) ) {
$t_domain = end( explode( '@', $p_email ) );

# see if we're limited to one domain
$t_limit_email_domain = config_get( 'limit_email_domain' );
@@ -844,8 +846,13 @@ function email_send_all($p_delete_on_failure = false) {

$t_emails_recipients_failed = array();
$t_start = microtime(true);
log_event( LOG_EMAIL, "Processing " . count( $t_ids ) . " queued messages" );
foreach( $t_ids as $t_id ) {
$t_email_data = email_queue_get( $t_id );
log_event( LOG_EMAIL,
"Sending message #$t_id queued on " .
date( config_get( 'complete_date_format' ), $t_email_data->submitted )
);

# check if email was not found. This can happen if another request picks up the email first and sends it.
if( $t_email_data === false ) {
@@ -886,10 +893,8 @@ function email_send( $p_email_data ) {
$t_mailer_method = config_get( 'phpMailer_method' );

if( is_null( $g_phpMailer ) ) {
if ( $t_mailer_method == PHPMAILER_METHOD_SMTP )
if ( $t_mailer_method == PHPMAILER_METHOD_SMTP ) {
register_shutdown_function( 'email_smtp_close' );
if( !class_exists( 'PHPMailer' ) ) {
require_once( BASE_PATH . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'phpmailer' . DIRECTORY_SEPARATOR . 'class.phpmailer.php' );
}
$mail = new PHPMailer(true);
} else {
@@ -952,27 +957,19 @@ function email_send( $p_email_data ) {

if( OFF !== $t_debug_email ) {
$t_message = 'To: ' . $t_recipient . "\n\n" . $t_message;
try {
$mail->AddAddress( $t_debug_email, '' );
} catch ( phpmailerException $e ) {
$t_success = false;
$mail->ClearAllRecipients();
$mail->ClearAttachments();
$mail->ClearReplyTos();
$mail->ClearCustomHeaders();
return $t_success;
}
} else {
try {
$mail->AddAddress( $t_recipient, '' );
} catch ( phpmailerException $e ) {
$t_success = false;
$mail->ClearAllRecipients();
$mail->ClearAttachments();
$mail->ClearReplyTos();
$mail->ClearCustomHeaders();
return $t_success;
}
$t_recipient = $t_debug_email;
}

try {
$mail->AddAddress( $t_recipient, '' );
} catch ( phpmailerException $e ) {
log_event( LOG_EMAIL, "ERROR: Message could not be sent - " . $e->getMessage() );
$t_success = false;
$mail->ClearAllRecipients();
$mail->ClearAttachments();
$mail->ClearReplyTos();
$mail->ClearCustomHeaders();
return $t_success;
}

$mail->Subject = $t_subject;
@@ -1138,7 +1135,8 @@ function email_bug_reminder( $p_recipients, $p_bug_id, $p_message ) {
$t_contents = $t_header . string_get_bug_view_url_with_fqdn( $p_bug_id, $t_recipient ) . " \n\n$p_message";

if( ON == config_get( 'enable_email_notification' ) ) {
email_store( $t_email, $t_subject, $t_contents );
$t_id = email_store( $t_email, $t_subject, $t_contents );
log_event( LOG_EMAIL, "queued reminder email #$t_id for U$t_recipient" );
}

lang_pop();
4 changes: 3 additions & 1 deletion core/email_queue_api.php
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
* @copyright Copyright (C) 2002 - 2012 MantisBT Team - mantisbt-dev@lists.sourceforge.net
* @link http://www.mantisbt.org
*/

/**
* EmailData Structure Definition
* @package MantisBT
@@ -163,6 +163,8 @@ function email_queue_delete( $p_email_id ) {

$query = 'DELETE FROM ' . $t_email_table . ' WHERE email_id=' . db_param();
db_query_bound( $query, Array( $c_email_id ) );

log_event( LOG_EMAIL, "message #$p_email_id deleted from queue" );
}

/**
7 changes: 6 additions & 1 deletion core/string_api.php
Original file line number Diff line number Diff line change
@@ -446,6 +446,7 @@ function string_process_bugnote_link( $p_string, $p_include_anchor = true, $p_de
*/
function string_insert_hrefs( $p_string ) {
static $s_url_regex = null;
static $s_url_replace = null;
static $s_email_regex = null;
static $s_anchor_regex = '/(<a[^>]*>.*?<\/a>)/is';

@@ -479,12 +480,16 @@ function string_insert_hrefs( $p_string ) {

$s_url_regex = "/(${t_url_protocol}(${t_url_part1}*?${t_url_part2}+))/sue";

# URL replacement
$t_url_href = "href=\"'.rtrim('\\1','.').'\"";
$s_url_replace = "'<a ${t_url_href}>\\1</a> [<a ${t_url_href} target=\"_blank\">^</a>]'";

# e-mail regex
$s_email_regex = substr_replace( email_regex_simple(), '(?:mailto:)?', 1, 0 );
}

# Find any URL in a string and replace it by a clickable link
$p_string = preg_replace( $s_url_regex, "'<a href=\"'.rtrim('\\1','.').'\">\\1</a> [<a href=\"'.rtrim('\\1','.').'\" target=\"_blank\">^</a>]'", $p_string );
$p_string = preg_replace( $s_url_regex, $s_url_replace, $p_string );
if( $t_change_quotes ) {
ini_set( 'magic_quotes_sybase', true );
}
4 changes: 2 additions & 2 deletions library/README.libs
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ adodb | adodb | 5.10 | patched: various, see git
disposable | disposable | 1.1.0 | unpatched
ezc | ez Components | 2009.2.1 | unpatched
nusoap | nusoap | 0.9.5 | patched: XSS vulnerabilities as per #12312
phpmailer | PHPMailer | 5.1 | unpatched
phpmailer | PHPMailer | 5.2.1 | unpatched
projax | projax | | unpatched
rssbuilder | RSSBuilder | 2.2.1 | patched: removed __autoload function
utf8 | phputf8 | 0.5 | unpatched
@@ -19,7 +19,7 @@ adodb - http://adodb.sourceforge.net/
disposable - http://github.com/vboctor/disposable_email_checker/tree/master
ezc - http://ezcomponents.org/
nusoap - http://sourceforge.net/projects/nusoap/
phpmailer - http://phpmailer.codeworxtech.com/
phpmailer - http://code.google.com/a/apache-extras.org/p/phpmailer/
projax - http://script.aculo.us/downloads / http://www.ngcoders.com/projax/
rssbuilder - http://code.google.com/p/flaimo-php/
utf8 - http://sourceforge.net/projects/phputf8
Loading