Argentini.Halide.H3Text.StripEmailHeaderProperties C# (CSharp) Method

StripEmailHeaderProperties() public static method

Remove all occurrences of dangerous email header properties from a string. This is used to prevent someone from inserting code into submitted form data that will trick the page into sending mail to other people.

E-mail header text that will be removed includes:

"x-mailer:", "x-rcpt-to:", "x-uidl:", "content-transfer-encoding:", "content-type:", "mime-version:", "x-sender:", "bcc:", "cc:", "x-receiver:"

public static StripEmailHeaderProperties ( string strVar ) : String
strVar string String to process.
return String
        public static String StripEmailHeaderProperties(string strVar)
        {
            string retVal = strVar;

            if (FixNull(strVar) != string.Empty)
            {
                retVal = HttpUtility.HtmlDecode(retVal);

                List<string> badWords = new List<string>();

                badWords.Add("x-mailer:");
                badWords.Add("x-rcpt-to:");
                badWords.Add("x-uidl:");
                badWords.Add("content-transfer-encoding:");
                badWords.Add("content-type:");
                badWords.Add("mime-version:");
                badWords.Add("x-sender:");
                badWords.Add("bcc:");
                badWords.Add("cc:");
                badWords.Add("x-receiver:");

                for (int x = 0; x < badWords.Count; x++)
                {
                    retVal = retVal.Replace(badWords[x], "");
                }
            }

            return retVal;
        }