Edgewall Software
Modify

Opened 11 years ago

Closed 10 years ago

Last modified 8 years ago

#8356 closed defect (fixed)

[PATCH] Email address in user preferences is not honored when user name contains an "@"

Reported by: Robert Widhopf-Fenk Owned by: Remy Blank
Priority: normal Milestone: 1.0
Component: notification Version: 0.11.1
Severity: major Keywords: consider, patch
Cc: lists@… Branch:
Release Notes:

Email address in user preferences are now used even when user name contains an "@"

API Changes:
Internal Changes:

Description (last modified by Remy Blank)

We are using http://modauthkerb.sourceforge.net/ for single sign on and this generates user names of the form USER@REALM. Users have set their email addresses in the preferences, but they are not used as the user name already contains an "@" and is considered as an email address.

The following patch against 0.11.1 changes the code to honor the email address if one is given and to do the other guessing only if there is none.

  • notification.

    old new  
    277277                return False
    278278            return True
    279279
    280         if not is_email(address):
    281             if address == 'anonymous':
     280        if address == 'anonymous':
     281            return None
     282
     283        if self.email_map.has_key(address):
     284            address = self.email_map[address]
     285        elif not is_email(address) and NotifyEmail.nodomaddr_re.match(address):
     286            if self.config.getbool('notification', 'use_short_addr'):
     287                return address
     288            domain = self.config.get('notification', 'smtp_default_domain')
     289            if domain:
     290                address = "%s@%s" % (address, domain)
     291            else:
     292                self.env.log.info("Email address w/o domain: %s" % address)
    282293                return None
    283             if self.email_map.has_key(address):
    284                 address = self.email_map[address]
    285             elif NotifyEmail.nodomaddr_re.match(address):
    286                 if self.config.getbool('notification', 'use_short_addr'):
    287                     return address
    288                 domain = self.config.get('notification', 'smtp_default_domain')
    289                 if domain:
    290                     address = "%s@%s" % (address, domain)
    291                 else:
    292                     self.env.log.info("Email address w/o domain: %s" % address)
    293                     return None
    294294
    295295        mo = self.shortaddr_re.search(address)
    296296        if mo:

Attachments (1)

8356-email-priority-r10321.patch (3.1 KB ) - added by Remy Blank 10 years ago.
Give the e-mail address priorty over guessing from the user name.

Download all attachments as: .zip

Change History (11)

comment:1 by anonymous, 11 years ago

Summary: Email addressin user preferences are not honored when user name looks like an email addessEmail address in user preferences is not honored when user name contains an "@"

comment:2 by Remy Blank, 11 years ago

Description: modified (diff)

comment:3 by Christian Boos, 11 years ago

Keywords: consider added
Milestone: 0.13

comment:4 by Remy Blank, 10 years ago

Milestone: next-major-0.1X0.13
Owner: changed from Emmanuel Blot to Remy Blank

comment:5 by Thijs Triemstra <lists@…>, 10 years ago

Cc: lists@… added

I tested the patch but couldn't see any difference, it always tried to send to my_email @ [smtp_default_domain]. Here's the same patch against 0.12-stable.

  • trac/notification.py

     
    355355                return False
    356356            return True
    357357
    358         if not is_email(address):
    359             if address == 'anonymous':
     358        if address == 'anonymous':
     359            return None
     360        if self.email_map.has_key(address):
     361            address = self.email_map[address]
     362        elif not is_email(address) and NotifyEmail.nodomaddr_re.match(address):
     363            if self.config.getbool('notification', 'use_short_addr'):
     364                return address
     365            domain = self.config.get('notification', 'smtp_default_domain')
     366            if domain:
     367                address = "%s@%s" % (address, domain)
     368            else:
     369                self.env.log.info("Email address w/o domain: %s" % address)
    360370                return None
    361             if self.email_map.has_key(address):
    362                 address = self.email_map[address]
    363             elif NotifyEmail.nodomaddr_re.match(address):
    364                 if self.config.getbool('notification', 'use_short_addr'):
    365                     return address
    366                 domain = self.config.get('notification', 'smtp_default_domain')
    367                 if domain:
    368                     address = "%s@%s" % (address, domain)
    369                 else:
    370                     self.env.log.info("Email address w/o domain: %s" % address)
    371                     return None
    372371
    373372        mo = self.shortaddr_re.search(address)
    374373        if mo:

in reply to:  5 comment:6 by Thijs Triemstra <lists@…>, 10 years ago

Replying to Thijs Triemstra <lists@…>:

to send to my_email @ [smtp_default_domain].

I meant my_trac_username @ [smtp_default_domain].

by Remy Blank, 10 years ago

Give the e-mail address priorty over guessing from the user name.

in reply to:  5 comment:7 by Remy Blank, 10 years ago

Replying to Thijs Triemstra <lists@…>:

I tested the patch but couldn't see any difference, it always tried to send to my_email @ [smtp_default_domain]. Here's the same patch against 0.12-stable.

I must have misunderstood your comment, because I thought your patch didn't fix the issue. I came up with exactly the same fix (in 8356-email-priority-r10321.patch), and it passes the modified test case that checks for this.

Could you please test again if this patch solves the issue for you? The symptoms you describe may be unrelated.

comment:8 by Thijs Triemstra <lists@…>, 10 years ago

Keywords: patch added
Summary: Email address in user preferences is not honored when user name contains an "@"[PATCH] Email address in user preferences is not honored when user name contains an "@"

Like I wrote in comment 5, I wasn't able to see a difference with the patch but I didn't have modauthkerb installed either so I'll leave it up to you rblank.

comment:9 by Remy Blank, 10 years ago

Resolution: fixed
Status: newclosed

Thanks for the feedback. Patch applied in [10347].

comment:10 by Christian Boos, 8 years ago

Release Notes: modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Remy Blank to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.