[MGNLMAIL-49] info.magnolia.module.mail.templates.MgnlEmail.EMAIL_WITH_PERSONAL_PATTERN is wrong and superfluous Created: 05/Nov/10  Updated: 16/Jan/15  Resolved: 15/Jan/15

Status: Closed
Project: Magnolia Mail Module
Component/s: Templates
Affects Version/s: None
Fix Version/s: 5.1.4, 5.2.2

Type: Bug Priority: Major
Reporter: Felix Rabe Assignee: Robert Šiška
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Cloners
is cloned by MAGNOLIA-6030 info.magnolia.module.mail.templates.M... Closed
Template:
Patch included:
Yes
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled

 Description   

The pattern is used in info.magnolia.module.mail.templates.MgnlEmail.setFrom(String). If you call e.g. setFrom("Felix Rabe <felix.rabe@magnolia-cms.com>") which is completely valid, it will go down the "else" branch, as the regular expression does not match anything without '"'s or anything with a whitespace before "<".

I propose to shorten the code to just:

    public void setFrom(String _from) {
        try {
            InternetAddress address = new InternetAddress(_from, True);
            this.setFrom(address);
        }
        catch (Exception e) {
            log.error("Could not set from field of email:" + e.getMessage());
        }
    }

and remove the wrong pattern altogether.


Generated at Mon Feb 12 06:03:08 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.