Coldfusion cflocation strange behavior

234 Views Asked by At

I am storing a google review URL in my database as:

https://www.google.com/search?CFID=ac59cfdf-bbad-4017-9759-e88054f3f242&CFTOKEN=0&q=njcomputerrepair%2Bbrick%2Bnj&oq=njcomp&aqs=chrome.1.69i60j69i59j69i60j69i57j0l2.2762j0j9&sourceid=chrome&ie=UTF-8#lrd=0x89c18348735c2907:0x59aa614832a36b22,3,

And then in my application I set that URL to a variable and I redirect the user to that URL using cflocation.

<cfquery name="geturl" datasource="#datasource#">
select (residential_ReviewURL) as redirectURL
from subscribers
</cfquery>

<!--- Redirect to main html redirect page --->
<cfoutput>
<cflocation url="#getURL.redirectURL#">
</cfoutput>

However the URL gets changed at some point because I think that Coldfusion doesn't like the characters in the URL and it replaces them with % or removes them. Therefore when the user hits the google page, the page doesn't process as it should.

Here is how the URL looks after the redirect:

https://www.google.com/search?CFID=ac59cfdf-bbad-4017-9759-e88054f3f242&CFTOKEN=0&CFID=ac59cfdf-bbad-4017-9759-e88054f3f242&CFTOKEN=0&q=njcomputerrepair%2Bbrick%2Bnj&oq=njcomp&aqs=chrome.1.69i60j69i59j69i60j69i57j0l2.2762j0j9&sourceid=chrome&ie=UTF-8#lrd%3D0x89c18348735c2907%3A0x59aa614832a36b22%2C3%2C

How can I stop ColdFusion from changing the URL and keep id exactly as how it is stored in the database?

UPDATE

So I found that URLdecode will preserve the string. Here is what I have.

#urlDecode(getURL.redirectURL)#

The output is as follows

https://www.google.com/search?CFID=ac59cfdf-bbad-4017-9759-e88054f3f242&CFTOKEN=0&q=njcomputerrepair+brick+nj&oq=njcomp&aqs=chrome.1.69i60j69i59j69i60j69i57j0l2.2762j0j9&sourceid=chrome&ie=UTF-8#lrd=0x89c18348735c2907:0x59aa614832a36b22,3,

Why is it adding CFID and CFTOKEN to the URL though? I have it turned off in my Application.CFM:

<cfapplication name="yaya" 
    clientmanagement="no" 
    sessionmanagement="no" 
    setclientcookies="no" 
    setdomaincookies="no"
    sessiontimeout="#CreateTimeSpan(0,2,0,0)#" 
    applicationtimeout="#CreateTimeSpan(1,0,0,0)#"
      >
1

There are 1 best solutions below

0
On

To help others coming here:

cflocation have a parameter addToken which needs to set to no if we do not want to add CFID and CFTOKEN to the generated URL.

Adobe CFML reference: https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-j-l/cflocation.html