Skip to main content
Participating Frequently
January 17, 2014
Question

binary data in a form field gets changed

  • January 17, 2014
  • 1 reply
  • 4250 views

I'm about to migrate a Coldfusion9 application running on SunOS to Coldfusion10 on Suse Linux.

The webpages work perfectly on the new installation.

However there is also kind of a system interface where clients post forms to a CF page where one of the form fields (intentionally) contains binary data mixed with plain text.

This worked perfectly on the old installation.

The formfield is taken out of the request using

<cfset requestContent="#form.fieldt#"/>

On the new installation this works for the plain text part, but the binary data is somehow changed.

Any idea how I can prevent Coldfusion from changing the binary data?

Thanks

Pedro

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
January 18, 2014

Can you please bear with me. What you say confuses me a bit. What do you mean by "This worked perfectly on the old installation"? What failed to work, and what did you expect?

Also, you say, "one of the form fields (intentionally) contains binary data mixed with plain text". However, the variable you have defined, requestContent, is neither binary nor a combination of binary and string. It is just a string.

Participating Frequently
January 20, 2014

"This worked perfectly on the old installation": What I meant is, that the data in the form field (i.e. binary data mixed with plain text) was in the variable requestContent as it was sent by the client.

"What failed to work": In Coldfusion10 on Suse Linux, the binary data is not anymore as it was sent by the client (altough the plain text part remains correct). Some bytes (of the binary data) are dropped and the others are changed.

"What did you expect": As described for the old installation.

Thanks for your help

Pedro

BKBK
Community Expert
Community Expert
January 20, 2014

Umhum, I see. What might likely have changed between the 2 installations is the encoding. If so, then the following should help:

<cfif isDefined("form.fieldt")>

    <cfset setEncoding("form", "UTF-8")>

    <cfset requestContent="#form.fieldt#">  

</cfif>

Should you wish to read more on encoding, take a look at this article by the inimitable Joel Spolsky: The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!).