Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-6030

info.magnolia.module.mail.templates.MgnlEmail.EMAIL_WITH_PERSONAL_PATTERN is wrong and superfluous

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • 4.5.25
    • None
    • None
    • None
    • Yes

      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.

        Acceptance criteria

              rsiska Robert Šiška
              rsiska Robert Šiška
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Task DoD