My Projects
Search Blog

Categories
Archives
Useful Links
Photo Albums
RSS

Powered by
BlogCFM v1.15

Vivio Technologies Dedicated Hosting
24 August 2006
Debugging ajaxCFC
Rey Bango posted this to cf-talk,and I thouht wothy of blogging.

Here's a tip that I wanted to share within everyone here. It may be
known but I only found out about it today and wanted to share.
If you ever get the dreaded "Invalid Reply from Server" message from
AjaxCFC, spark up Firefox/FireBug and call your site from your local IP.
This will give you the actual message that DWR is sending back.

Put a stop point at about line 517 (or immediately after
"batch.req.send(query);") of engine.js and look for the "batch" object.
In the there you'll find the "req" (XMLHttpRequest request) object which
has a standard attribute called responseText. That will give you all of
the details of your error but for security reasons, it only shows it via
your local IP address (127.0.0.1).

Rey...
Posted by rickroot at 5:53 PM | Link | 2 comments
26 February 2006
ajaxCFC changes license

Rob Gonda announced in his blog the other day that he's changed the license for ajaxCFC from a restricted open source license in which permission was required to redistribute it, to a more formal open source license.  He's chosen the Apache 2.0 license.

Thanks Rob!

Posted by rickroot at 8:02 AM | Link | 0 comments
18 February 2006
Getting CFAJAX to handle Safari properly

The following applies to CFAJAX version 1.3.  I don't know about previous versions, and I certainly don't know about future versions!

I've noticed that CFAJAX seems to have with Safari. I've also noticed that other people have noticed as well.

Although my chat room worked for Safari users, Safari seemed to urlencode the parameters, and cf did not decode them.  Almost as if Safari URL encoded the parameters, and then URL encoded the whole XML packet.. so when coldfusion received the XML packet, it URL decoded it, and the parameters were still urlencoded.  Crazy!

So a safari user would type "hey just checking this out", and it would get passed to my functions as "hey%20just%20checking%20this%20out".

Here's my solution to this problem:

In the "convertDataPassedToCFFunctionParam" function, around line 90ish, just after the <cfelse> tag, I replaced the single line that was there (that starts with <cfset variable.param = listAppend ... >) with the following:

<cfif lcase(cgi.HTTP_USER_AGENT) contains "safari">
<cfset variables.param = ListAppend(variables.param,"""" & URLDecode(Replace(Replace(mid(variables.var, variables.firstPos+1 , len(variables.var)-variables.firstPos),Chr(34),"#Chr(34)##Chr(34)#","ALL"),Chr(35),"#Chr(35)##Chr(35)#","ALL")) & """")>
<cfelse>
<cfset variables.param = ListAppend(variables.param,"""" & Replace(Replace(mid(variables.var, variables.firstPos+1 , len(variables.var)-variables.firstPos),Chr(34),"#Chr(34)##Chr(34)#","ALL"),Chr(35),"#Chr(35)##Chr(35)#","ALL") & """")>
</cfif>


Basically, if the browser is safari, URLDecode the parameter value before placing it into the list. Otherwise, don't.

Posted by rickroot at 4:58 PM | Link | 5 comments
17 February 2006
CFAJAX Chat - Coming Soon, Demo Online!

In an effort to teach myself Ajax, I've written what I think is a pretty nice chat room application that I'll be releasing the source for soon.

Project: CFAJAX Chat
Home page: http://www.opensourcecf.com/cfajaxchat
Author: Rick Root
License: GPL
Platform: CFMX 6.1+, Bluedragon 6.2+ (?)
Description: Description: CFAJAX Chat is a multi-user chat room application written in CFML and making use of AJAX technology with the help of CFAJAX.
Posted by rickroot at 8:17 AM | Link | 0 comments
16 February 2006
Security Flaw in CFAJAX

While working on my new chat room project using CFAJAX, I discovered a pretty nasty security flaw in the cfajax framework.

Basically, if you have built an application that takes user input as a text string, and passes that text string to a coldfusion function on the server, then chances are good that your application allows people to execute CFML code on your server that you don't want them to.

I discovered it when I was having trouble with my chat application and the double quote mark ".  Any time I used a double quote in whatever I typed and sent to the server, it would cause a CFML error on the back said.

I realized that if I typed the following line, the CFML in the middle would be executed:

foo " & now() & " foo

And then someone else noticed that you could type in #Now()# and it would be executed on the server.

The flaw is basically in the way cfajax (in the file cfajax.cfm) constructs the functionName variable.

To resolve the problem, on or around line 92, in the listAppend() command that appends to the variables.param list, you have to escape both quotes and pound signs by doubling them up, as follows:

<cfset variables.param = ListAppend(variables.param,"""" &
Replace(Replace(mid(variables.var, variables.firstPos+1 ,
len(variables.var)-variables.firstPos),Chr(34),"#Chr(34)##Chr(34)#","ALL"),Chr(35),"#Chr(35)##Chr(35)#","ALL")
& """")>

 

I think that's enough to solve the problem, and it didn't adversely affect anything else - at least not that I was doing.
Posted by rickroot at 7:27 AM | Link | 0 comments