diff --git a/src/formulate.app/Forms/Handlers/Email/EmailHandler.cs b/src/formulate.app/Forms/Handlers/Email/EmailHandler.cs index 8a78f2c0..6e55c5b9 100644 --- a/src/formulate.app/Forms/Handlers/Email/EmailHandler.cs +++ b/src/formulate.app/Forms/Handlers/Email/EmailHandler.cs @@ -60,10 +60,13 @@ public class EmailHandler : IFormHandlerType public EmailHandler(IConfigurationManager configurationManager) { Config = configurationManager; + var options = RegexOptions.Compiled; + LineBreakRegex = new Regex(@"\r\n|\r(?!\n)|(? @@ -88,6 +91,7 @@ public EmailHandler(IConfigurationManager configurationManager) #endregion + #region Private Properties /// @@ -96,9 +100,9 @@ public EmailHandler(IConfigurationManager configurationManager) private IConfigurationManager Config { get; set; } /// - /// Precompiled regex for finding line breaks. + /// Matches line breaks. /// - private static Regex LineBreakRegex = new Regex(@"(\r\n|\r(?!\n)|(? LineBreakRegex.Replace(WebUtility.HtmlEncode(x), - Environment.NewLine + "
" + Environment.NewLine)).ToList(); + lines = lines + .Select(x => WebUtility.HtmlEncode(x)) + .Select(x => LineBreakRegex.Replace(x, nl)) + .ToList(); } // Return message. @@ -555,4 +560,4 @@ private object AttemptGetValue(Dictionary dictionary, string key #endregion } -} +} \ No newline at end of file