Cleaned & Hardened Email.cs
This commit is contained in:
@@ -1,29 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace smtpproxy.net;
|
||||
|
||||
public class Email
|
||||
namespace smtpproxy.net
|
||||
{
|
||||
public string FromIP;
|
||||
|
||||
public string sHELO;
|
||||
|
||||
public string sMAIL;
|
||||
|
||||
public string sDATA;
|
||||
|
||||
public List<string> sRCPTs;
|
||||
|
||||
public string GetRecipientEmail(string sRCPTTo)
|
||||
public class Email
|
||||
{
|
||||
return sRCPTTo.ToLower().Replace("rcpt to:", "").Replace("<", "")
|
||||
.Replace(">", "")
|
||||
.Replace("\r", "")
|
||||
.Replace("\n", "");
|
||||
}
|
||||
public string FromIP { get; set; }
|
||||
public string sHELO { get; set; }
|
||||
public string sMAIL { get; set; }
|
||||
public string sDATA { get; set; }
|
||||
public List<string> sRCPTs { get; set; }
|
||||
|
||||
public Email()
|
||||
{
|
||||
FromIP = string.Empty;
|
||||
sHELO = string.Empty;
|
||||
sMAIL = string.Empty;
|
||||
sDATA = string.Empty;
|
||||
sRCPTs = new List<string>();
|
||||
}
|
||||
|
||||
public string GetRecipientEmail(string sRCPTTo)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sRCPTTo))
|
||||
return string.Empty;
|
||||
|
||||
string cleaned = sRCPTTo
|
||||
.Replace("\r", "")
|
||||
.Replace("\n", "")
|
||||
.Replace("<", "")
|
||||
.Replace(">", "")
|
||||
.Trim();
|
||||
|
||||
if (cleaned.StartsWith("rcpt to:", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
cleaned = cleaned.Substring(8).Trim();
|
||||
}
|
||||
else if (cleaned.StartsWith("rcpt to", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
cleaned = cleaned.Substring(7).Trim();
|
||||
}
|
||||
|
||||
return cleaned.ToLowerInvariant();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user