i'm not sure exactly how to test this, so I'm just...
# cfml-general
t
i'm not sure exactly how to test this, so I'm just going to ask and see if anyone knows: When passing a URL to cfhttp with dynamic bits, does CF somehow escape those the way is does with
cfhttpparam type="url"
, or do I have to make sure to encode those myself?
Looks like it does not escape. So
<http://api.site.com/api/v#encodeForURL(versionNumber)#/#encodeForURL(taxYear)#/#encodeForURL(id)#|api.site.com/api/v#encodeForURL(versionNumber)#/#encodeForURL(taxYear)#/#encodeForURL(id)#>
is the way to go.
b
Hmm, quite. But funny you should say that. When I did a test I found the question to be trickier than I had thought.
<!--- Test by switching between these two statements: --->
<cfset testVariable="<testTag>">
<!---<cfset testVariable=encodeforurl("<testTag>")>--->
<cfhttp url="<http://localhost:8500/CF_Project/#testVariable#/index.cfm>" result="result">
<cfhttpparam type="url" name="urlVar" value="#testVariable#" >
</cfhttp>
When you use the first statement, then you get the following in the the logs: > http.log > "Information","http-nio-8500-exec-9","09/10/24","143322","MyApp1","Starting HTTP request {URL='http://localhost:8500/CF_Project/testTag/index.cfm?urlVar=%3CtestTag%3E', method='get'}" > > coldfusion-out-log > Sep 10, 2024 143322 PM Information [http-nio-8500-exec-9] - Starting HTTP request {URL='http://localhost:8500/CF_Project/testTag/index.cfm?urlVar=%3CtestTag%3E', method='get'} > Sep 10, 2024 143322 PM Error [http-nio-8500-exec-8] - File not found: /CF_Project/<testTag>/index.cfm The specific sequence of files included or processed is: C:\ColdFusion2023\cfusion\wwwroot\CF_Project\testTag\index.cfm'' When you use the second statement, the logs are: > http.log > "Information","http-nio-8500-exec-4","09/10/24","143340","MyApp1","Starting HTTP request {URL='http://localhost:8500/CF_Project/%3CtestTag%3E/index.cfm?urlVar=%253CtestTag%253E', method='get'}" > > coldfusion-out-log > Sep 10, 2024 143340 PM Information [http-nio-8500-exec-4] - Starting HTTP request {URL='http://localhost:8500/CF_Project/%3CtestTag%3E/index.cfm?urlVar=%253CtestTag%253E', method='get'} > Sep 10, 2024 143340 PM Error [http-nio-8500-exec-3] - File not found: /CF_Project/<testTag>/index.cfm The specific sequence of files included or processed is: C:\ColdFusion2023\cfusion\wwwroot\CF_Project\testTag\index.cfm'' • In the first case, urlVar is '%3CtestTag%3E'. In the second case, it is '%253CtestTag%253E'; • In both cases, the file-not-found log line contains '<testTag>'; • In both cases, the log line for specific file included contains 'testTag'