mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-02-07 12:52:52 -05:00
Add HTML decode for email preview in case sender sends html encoded chars in plain text (#1585)
This commit is contained in:
committed by
Leendert de Borst
parent
44ad686898
commit
fe0bb3a031
@@ -189,8 +189,11 @@ public class DatabaseMessageStore(ILogger<DatabaseMessageStore> logger, Config c
|
||||
{
|
||||
if (email.MessagePlain != null && !string.IsNullOrEmpty(email.MessagePlain) && email.MessagePlain.Length > 3)
|
||||
{
|
||||
// Decode HTML entities (e.g., ' -> ', & -> &)
|
||||
string plainToPlainText = System.Net.WebUtility.HtmlDecode(email.MessagePlain);
|
||||
|
||||
// Replace any newline characters with a space
|
||||
string plainToPlainText = Regex.Replace(email.MessagePlain, @"\t|\n|\r", " ", RegexOptions.NonBacktracking);
|
||||
plainToPlainText = Regex.Replace(plainToPlainText, @"\t|\n|\r", " ", RegexOptions.NonBacktracking);
|
||||
|
||||
// Remove all "-" or "=" characters if there are 3 or more in a row
|
||||
plainToPlainText = Regex.Replace(plainToPlainText, @"-{3,}|\={3,}", string.Empty, RegexOptions.NonBacktracking);
|
||||
@@ -212,6 +215,9 @@ public class DatabaseMessageStore(ILogger<DatabaseMessageStore> logger, Config c
|
||||
{
|
||||
string htmlToPlainText = Uglify.HtmlToText(email.MessageHtml).ToString();
|
||||
|
||||
// Decode HTML entities (e.g., ' -> ', & -> &)
|
||||
htmlToPlainText = System.Net.WebUtility.HtmlDecode(htmlToPlainText);
|
||||
|
||||
// Replace any newline characters with a space
|
||||
htmlToPlainText = Regex.Replace(htmlToPlainText, @"\t|\n|\r", string.Empty, RegexOptions.NonBacktracking);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user