Skip to content

Instantly share code, notes, and snippets.

@orangexception
Created February 28, 2012 16:27
Show Gist options
  • Save orangexception/1933472 to your computer and use it in GitHub Desktop.
Save orangexception/1933472 to your computer and use it in GitHub Desktop.
Things could get grimmy
<cffunction name= "grimRequestStructure"
output= "false"
access= "private"
hint= "I convert valid html escaped strings into their code format.">
<cfargument name= "stTarget" />
<cfargument name= "bDuplicate"
required= "false"
default= "true"
hint= "I toggle duplicating the stTarget. If set to false, I simply override values in stTarget." />
<cfscript>
var sKey= "";
var stCopy= stTarget;
if( bDuplicate )
stCopy= duplicate( stTarget );
for( sKey in stTarget ) {
if( IsStruct( stCopy[ sKey ] ) ) {
stCopy[ sKey ]= grimRequestStructure( stCopy[ sKey ] );
}
else if ( IsSimpleValue( stCopy[ sKey ] ) ) {
stCopy[ sKey ]= REReplace( stCopy[ sKey ] ,
"&lt;" ,
'<' ,
"all" );
stCopy[ sKey ]= REReplace( stCopy[ sKey ] ,
"&gt;" ,
'>' ,
"all" );
stCopy[ sKey ]= REReplace( stCopy[ sKey ] ,
"&amp;" ,
'&' ,
"all" );
stCopy[ sKey ]= REReplace( stCopy[ sKey ] ,
"&quot;" ,
'"' ,
"all" );
}
}
return stCopy;
</cfscript>
</cffunction>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment