diff --git a/src/Core/Services/Implementations/RazorMailService.cs b/src/Core/Services/Implementations/RazorMailService.cs index fb53bf5d9..d4edad65f 100644 --- a/src/Core/Services/Implementations/RazorMailService.cs +++ b/src/Core/Services/Implementations/RazorMailService.cs @@ -7,6 +7,7 @@ using Bit.Core.Models.Mail; using RazorLight.Templating; using System.IO; using System.Net; +using Bit.Core.Utilities; namespace Bit.Core.Services { @@ -118,7 +119,7 @@ namespace Bit.Core.Services var message = CreateDefaultMessage("Your Master Password Hint", email); var model = new MasterPasswordHintViewModel { - Hint = hint, + Hint = CoreHelpers.SanitizeForEmail(hint), WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash, SiteName = _globalSettings.SiteName }; @@ -146,7 +147,7 @@ namespace Bit.Core.Services var message = CreateDefaultMessage($"User {userEmail} Has Accepted Invite", adminEmails); var model = new OrganizationUserAcceptedViewModel { - OrganizationName = organizationName, + OrganizationName = CoreHelpers.SanitizeForEmail(organizationName), UserEmail = userEmail, WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash, SiteName = _globalSettings.SiteName @@ -161,7 +162,7 @@ namespace Bit.Core.Services var message = CreateDefaultMessage($"You Have Been Confirmed To {organizationName}", email); var model = new OrganizationUserConfirmedViewModel { - OrganizationName = organizationName, + OrganizationName = CoreHelpers.SanitizeForEmail(organizationName), WebVaultUrl = _globalSettings.BaseServiceUri.VaultWithHash, SiteName = _globalSettings.SiteName }; @@ -175,7 +176,7 @@ namespace Bit.Core.Services var message = CreateDefaultMessage($"Join {organizationName}", orgUser.Email); var model = new OrganizationUserInvitedViewModel { - OrganizationName = organizationName, + OrganizationName = CoreHelpers.SanitizeForEmail(organizationName), Email = WebUtility.UrlEncode(orgUser.Email), OrganizationId = orgUser.OrganizationId.ToString(), OrganizationUserId = orgUser.Id.ToString(), diff --git a/src/Core/Utilities/CoreHelpers.cs b/src/Core/Utilities/CoreHelpers.cs index 257d8f6f0..e2f4cf1d7 100644 --- a/src/Core/Utilities/CoreHelpers.cs +++ b/src/Core/Utilities/CoreHelpers.cs @@ -411,5 +411,12 @@ namespace Bit.Core.Utilities } return sb.ToString(); } + + public static string SanitizeForEmail(string value) + { + return value.Replace("@", "[at]") + .Replace("http://", string.Empty) + .Replace("https://", string.Empty); + } } }