> Yeah, that's true; my bad.  But as you say, it's also
> insecure.  Far
> better, and my preference, is be to do something like
> this:

> <cfparam name="attributes.join" default="left">
> <cfquery name="getStuff" ...>
>        select b.*, j.columns
>        from basetable b
>        <cfif attributes.join EQ "left">
>          left
>        <cfelseif attributes.join EQ "right">
>          right
>        <cfelse>
>          inner
>        </cfif> jointable j on (j.x = b.x)
> </cfquery>

> No more hashes, no more security issues, and you even get
> handling
> (though with a default, not a raised exception) for
> invalid values.

I'd use a cfswitch for that...

<cfswitch expression="#attributes.join#">
        <cfcase value="left,right,inner" delimiters=",">
                #attributes.join#
        </cfcase>
        <cfdefaultcase>inner</cfdefaultcase>
</cfwitch>

or this

<cfif not listfindnocase("left,right,inner",trim(attributes.join))>
        <cfset attributes.join = "inner">
</cfif>

Though in my case it's not done this way either... I have a join
tag/function that accepts a boolean "required" attribute/argument...
The join is "inner" if the join is required, otherwise it's "left".
But the db access tags also perform a fair amount of massaging on the
table and column names, to do things like ensure that the names of
filter columns match columns in the table -- if not the filter is
ignored. This allows things like #sql.structToFilters()# (the default
for sql.select()) which converts a collection of strings into an array
of the attributes accepted by the filter tag to allow automated
filtering of list pages and the like. So when I create my list pages,
they're searchable by default without my having to add anything
special to the page to make the content searchable. In any event --
all these features require that I use hashed variables in the cfquery
tag (I can't switch-case or cfif every column name a person could
conceivably use), although since they're checked against the meta-data
for the table prior to executing the query that provides the security.



s. isaac dealey   954.522.6080
new epoch : isn't it time for a change?

add features without fixtures with
the onTap open source framework

http://www.fusiontap.com
http://coldfusion.sys-con.com/author/4806Dealey.htm




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:210634
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to