This content has been marked as final. Show 6 replies
Have you considered using a different type in your cfparam tag?
I don't believe "numeric" is a valid type in CFPARAM.
I reread your posting after I first responded (novel concept) and it seems that ColdFusion gobbled up the integer and everything to tright of it in the URL. Strange. It seems to have missed the "&" at the end of the integer. Maybe you have some non-printing characters, like ASCII 10 or 13 in the URL and don't know it.
your cfparam should validate it fine. i tested it and it works.
the problem is, your url is url-encoded. the '&' sign in it is actually '%26' and coldfusion does not see a variable separator and treats your whole query string as one variable/name pair instead of two.
why your url got url-encoded and how to work around it is another question...
I'm sure you've hit the nail on the head.
I think it has to do with the CFCONTENT tag. So how do I stop the URL from becoming encoded? Or test to see if it is encoded and then decode?
> I don't believe "numeric" is a valid type in CFPARAM.
You are correct.
Numeric is not listed in the CFMX 7 docs as a valid type for the cfparam tag.
However, it is listed as a valid type for CF ver 6.1 and ver 5.0
It seems to me that the cfparam tag should behave differently when using
the two different types (numeric vs integer).
For example what if the number to be passed is a really large number...
Or any number larger than 2147483647 for that matter.
i believe you can't 'decode' a url and still use it as a structure and
retrieve individual keys from it...
i guess what you will have to do is:
1) decode the cgi.query_string variable
2) create a new structure
3) populate it with elements of the decoded cgi.query_string
4) use your cfparam validation on the new structure
here is a sample code that has worked for me. comments in code:
<!--- decode the cgi.query_string and assign its new value to a tmp
<cfset tmp = #urldecode(cgi.QUERY_STRING)#>
<!--- create new empty structure --->
<cfset tmp2 = structnew()>
<!--- loop through the tmp var as a list with '&' as delimiters,
storing each key/value pair in a listEl item
(your listEl itimes will now consist of all xxx=yyy pairs from your
<cfloop index="listEl" list="#tmp#" delimiters="&">
<!--- for each listEl item created by cfloop, create a key and value
and insert them as key and value into the tmp2 structure created before
<cfset tmp2_key = listgetat(listEl, 1, "=")><!--- create a key var and
assign it the xxx value from the listEl --->
<cfset tmp2_val = listgetat(listEl, 2, "=")><!--- create a val var and
assign it the yyy value from the listEl --->
StructInsert(tmp2, tmp2_key, tmp2_val, "true");<!--- this cfscript
populates our tmp2 structure with all key/value pairs --->
<!--- debug & test : remove this from production version --->
<cfdump var="#tmp2#"><!--- dump the new tmp2 structure --->
<!--- below i am using a isValid cf function to test that eventID is an
integer. you will use your cfparam. isvalid just allows me to assign
an output to evaluation that i can see --->
<cfif isvalid("integer", tmp2.eventID)>