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: f9b9e2fc4356
Choose a base ref
...
head repository: mantisbt/mantisbt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6da5164e35ff
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Jul 6, 2012

  1. Whitespace fixes

    dregad committed Jul 6, 2012
    Copy the full SHA
    63f044a View commit details
  2. Fix email validation regex rejects addresses with single subdomain

    Per RFC 5322, e.g. user@localhost is a valid e-mail address but the
    previously implemented regex rejected it.
    
    Fixes #14453
    dregad committed Jul 6, 2012
    Copy the full SHA
    6da5164 View commit details
Showing with 33 additions and 24 deletions.
  1. +33 −24 core/email_api.php
57 changes: 33 additions & 24 deletions core/email_api.php
Original file line number Diff line number Diff line change
@@ -57,15 +57,24 @@
$g_phpMailer = null;

/**
*
* Use a simple perl regex for valid email addresses. This is not a complete regex,
* as it does not cover quoted addresses or domain literals, but it is simple and
* covers the vast majority of all email addresses without being overly complex.
* @return string
*/
function email_regex_simple() {
return "/([a-z0-9!#*+\/=?^_{|}~-]+(?:\.[a-z0-9!#*+\/=?^_{|}~-]+)*)" . # recipient
"\@((?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)/i"; # @domain
static $s_email_regex = null;

if( is_null( $s_email_regex ) ) {
$t_recipient = "([a-z0-9!#*+\/=?^_{|}~-]+(?:\.[a-z0-9!#*+\/=?^_{|}~-]+)*)";

# a domain is one or more subdomains
$t_subdomain = "(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)";
$t_domain = "(${t_subdomain}(?:\.${t_subdomain})*)";

$s_email_regex = "/${t_recipient}\@${t_domain}/";
}
return $s_email_regex;
}

/**
@@ -417,7 +426,7 @@ function email_collect_recipients( $p_bug_id, $p_notify_type, $p_extra_user_ids_
* @param int $p_user_id
* @param string $p_password
* @param string $p_confirm_hash
* @param string $p_admin_name
* @param string $p_admin_name
* @return null
*/
function email_signup( $p_user_id, $p_password, $p_confirm_hash, $p_admin_name = '' ) {
@@ -532,7 +541,7 @@ function email_notify_new_account( $p_username, $p_email ) {
* send a generic email
* $p_notify_type: use check who she get notified of such event.
* $p_message_id: message id to be translated and included at the top of the email message.
* Return false if it were problems sending email * @param string
* Return false if it were problems sending email * @param string
* @param int $p_bug_id
* @param string $p_notify_type
* @param int $p_message_id
@@ -653,9 +662,9 @@ function email_relationship_child_closed( $p_bug_id ) {

/**
* send notices to all the handlers of the parent bugs still open when a child bug is resolved/closed
*
*
* @param int $p_bug_id
* @param int $p_message_id
* @param int $p_message_id
* @return null
*/
function email_relationship_child_resolved_closed( $p_bug_id, $p_message_id ) {
@@ -684,7 +693,7 @@ function email_relationship_child_resolved_closed( $p_bug_id, $p_message_id ) {

/**
* send notices when a bug is sponsored
* @param int $p_bug_id
* @param int $p_bug_id
* @return null
*/
function email_sponsorship_added( $p_bug_id ) {
@@ -693,7 +702,7 @@ function email_sponsorship_added( $p_bug_id ) {

/**
* send notices when a sponsorship is modified
* @param int $p_bug_id
* @param int $p_bug_id
* @return null
*/
function email_sponsorship_updated( $p_bug_id ) {
@@ -702,7 +711,7 @@ function email_sponsorship_updated( $p_bug_id ) {

/**
* send notices when a sponsorship is deleted
* @param int $p_bug_id
* @param int $p_bug_id
* @return null
*/
function email_sponsorship_deleted( $p_bug_id ) {
@@ -711,7 +720,7 @@ function email_sponsorship_deleted( $p_bug_id ) {

/**
* send notices when a new bug is added
* @param int $p_bug_id
* @param int $p_bug_id
* @return null
*/
function email_new_bug( $p_bug_id ) {
@@ -720,7 +729,7 @@ function email_new_bug( $p_bug_id ) {

/**
* send notices when a new bugnote
* @param int $p_bug_id
* @param int $p_bug_id
* @return null
*/
function email_bugnote_add( $p_bug_id ) {
@@ -729,7 +738,7 @@ function email_bugnote_add( $p_bug_id ) {

/**
* send notices when a bug is RESOLVED
* @param int $p_bug_id
* @param int $p_bug_id
* @return null
*/
function email_resolved( $p_bug_id ) {
@@ -738,7 +747,7 @@ function email_resolved( $p_bug_id ) {

/**
* send notices when a bug is CLOSED
* @param int $p_bug_id
* @param int $p_bug_id
* @return null
*/
function email_close( $p_bug_id ) {
@@ -747,7 +756,7 @@ function email_close( $p_bug_id ) {

/**
* send notices when a bug is REOPENED
* @param int $p_bug_id
* @param int $p_bug_id
* @return null
*/
function email_reopen( $p_bug_id ) {
@@ -756,7 +765,7 @@ function email_reopen( $p_bug_id ) {

/**
* send notices when a bug is ASSIGNED
* @param int $p_bug_id
* @param int $p_bug_id
* @return null
*/
function email_assign( $p_bug_id ) {
@@ -774,7 +783,7 @@ function email_bug_deleted( $p_bug_id ) {

/**
* Store email in queue for sending
*
*
* @param string $p_recipient
* @param string $p_subject
* @param string $p_message
@@ -860,7 +869,7 @@ function email_send_all($p_delete_on_failure = false) {

/**
* This function sends an email message based on the supplied email data.
*
*
* @param EmailData $p_email_data
* @return bool
*/
@@ -1016,8 +1025,8 @@ function email_send( $p_email_data ) {

/**
* closes opened kept alive SMTP connection (if it was opened)
*
* @param string
*
* @param string
* @return null
*/
function email_smtp_close() {
@@ -1035,7 +1044,7 @@ function email_smtp_close() {
/**
* formats the subject correctly
* we include the project name, bug id, and summary.
*
*
* @param int $p_bug_id
* @return null
*/
@@ -1054,7 +1063,7 @@ function email_build_subject( $p_bug_id ) {

/**
* clean up LF to CRLF
*
*
* @param string $p_string
* @return null
*/
@@ -1197,7 +1206,7 @@ function email_bug_info_to_one_user( $p_visible_bug_data, $p_message_id, $p_proj

/**
* Build the bug info part of the message
* @param array $p_visible_bug_data
* @param array $p_visible_bug_data
* @return string
*/
function email_format_bug_message( $p_visible_bug_data ) {
@@ -1360,7 +1369,7 @@ function email_format_attribute( $p_visible_bug_data, $attribute_id ) {
* return array with bug data. See usage in email_format_bug_message(...)
* @param int $p_user_id
* @param int $p_bug_id
* @param string $p_message_id
* @param string $p_message_id
* @return array
*/
function email_build_visible_bug_data( $p_user_id, $p_bug_id, $p_message_id ) {