I am building a dynamic SQL Query using CFLoop
.
I am using CFSaveContent
to iterate through the variables and build the query and then I am executing it in CFQuery
using PreserveSingleQuotes
.
That works fine but the issue with this method is that I can't use CFQueryParam
so my query is vulnerable for injections.
Is was wondering if there is any workaround for this issue?
Update:
<cfsavecontent variable="sqlstring">
SELECT id
,(CASE
<cfloop query="qGetRules">
WHEN val1 >=#qGetRules.equ# AND val2 >#arguments.leve# THEN 1
</cfloop>
ELSE 0
END) AS criteria
FROM mt4_users
</cfsavecontent>
<cfquery name="qGetEquity" datasource="mydatasource">
#PreserveSingleQuotes(variables.sqlstring)#
</cfquery>
So on this example as you can see I can't use cfqueryparam
for the arguments.leve
because it will crash on PreserveSingleQuotes