Damon Maneice
Damon Maneice

Reputation: 11

ColdFusion cfhttp strips out newline character from parameter

Before calling the function below, the text1 value was encoded ie:

http://example/exampleProxy.cfc?returnFormat=plain&method=update&id=443&blah=something&text1=bob+bob2%0Abob

But the request that is sent has stripped out the newline character ie

http://example/test/id=443&blah=something&text1=bob+bob2bob

Function:

<cffunction name="update" access="remote" output="yes" returntype="string">
        <cfargument name="id" required="yes" type="string" />
        <cfargument name="blah" required="yes" type="string" />
        <cfargument name="text1" required="yes" type="string" />   

        <cfhttp url="#variables.cString#" method="PUT"      timeout="#variables.HTTP_TIMEOUT#">
            <cfhttpparam name="id" type="url" value="#arguments.id#">
            <cfhttpparam name="blah" type="url" value="#arguments.blah#">
            <cfhttpparam name="text1" type="url" value="#arguments.text1#">
        </cfhttp>
        ...

Upvotes: 1

Views: 462

Answers (2)

barnyr
barnyr

Reputation: 5678

Another way to confirm whether anything is being stripped is to run Fiddler and add proxyserver="localhost" proxyport="8888" to your call. the call will be routed through fiddler and you can inspect all the parameters from there

Upvotes: 1

Leigh
Leigh

Reputation: 28873

From what you have described, I suspect the new line character is there. But you would not be able to see it with a simple <cfdump var="..."> because it displays the results html. So any new line characters will just appear as a single space:

TEXT1: bob bob2 bob  

You either need to use format="text" or <pre> tags. Then you should see the new line character in the value:

Code:

<cfdump var="#arguments#" format="text">
<pre>TEXT1: #arguments.text1#</pre>

Results:

BLAH: something
ID: 443
TEXT1: bob bob2   <--- new line
bob


TEXT1: bob bob2  <--- new line
bob

I tested your code with CF9, and the new line was present inside the function and on the receiving page. ie CGI.QUERY_STRING

  id=443&blah=something&text1=bob%20bob2%0Abob 

Upvotes: 2

Related Questions