CFLib.org – Common Function Library Project

trimFalseEmailHeaders(str)

Last updated February 3, 2006

Version: 1 | Requires: ColdFusion 5 | Library: SecurityLib

 
Rated 4 time(s). Average Rating: 3.0

Description:
Clean variables, such as form input, to modify values that may have been entered to perform e-mail injection. This includes 'content-type','mime-version','to','bcc' and 'subject'. It keeps the value intact, but replaces colons to avoid injection. Credit to: http://www.webmasterworld.com/forum10/9776-2-10.htm E-mail injection: http://en.wikipedia.org/wiki/Email_Injection

Return Values:
Returns a string.

Example:

view plain print about
<cfset mailTo = "test@domain.com">
<cfset mailBody = "test injection#CHR(10)#Content-type: text/plain#CHR(10)#">

<cfset cleanMailBody = trimFalseEmailHeaders(mailBody )>

Parameters:

Name Description Required
str String to parse. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Clean variables, such as form input, to modify values that may have been entered to perform e-mail injection.
 * 
 * @param str      String to parse. (Required)
 * @return Returns a string. 
 * @author Tony Brandner (tony@brandners.com) 
 * @version 1, February 3, 2006 
 */

function trimFalseEmailHeaders(str) {
    str = replaceNoCase(str, "Content-Type:""content-type;""ALL" );
    str = replaceNoCase(str, "MIME-Version:""mime-version;""ALL" );
    str = replaceNoCase(str, "To: ""to; ""ALL" );
    str = replaceNoCase(str, "From: ""from; ""ALL" );
    str = replaceNoCase(str, "bcc: ""bcc; ""ALL" );
    str = replaceNoCase(str, "Subject: ""subject; ""ALL" );
    return str;
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Tayo Akinmade Tayo Akinmade added
arrayTrim
11 day(s) ago

Will Belden Will Belden added
longTime
17 day(s) ago

James Sleeman James Sleeman added
quickSort
27 day(s) ago

Ben Forta Ben Forta added
GetHostAddress
30 day(s) ago

Top Rated

Darwan Leonardo Sitepu EksporSQLData
Rated 5.0, 16 time(s)

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 13 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson