Re: Cf9 http POST in Taffy API screws up Thai characters

38 views
Skip to first unread message
Message has been deleted

Adam Tuttle

unread,
Nov 8, 2016, 11:38:09 AM11/8/16
to Taffy Users
> this must surely have been noticed before by anyone using Cf9 and Taffy in an international context where some 3rd-party application is calling the published Taffy Api

I suspect you're correct in that regard, but aside from the stack overflow post you linked I don't recall it ever coming up.

You can't ask the client to use <cfprocessingdirective> but you can (and should) have them send the Content-Type header with UTF-8 as the charset.

Adam

On Tue, Nov 8, 2016 at 11:07 AM, Bill Tudor <ahoy...@gmail.com> wrote:
A question of character,

We are publishing an Api via Taffy that uses a POST whereby a 3rd party can send the status & location of an order. We update our application with this data. All is fine when they send the location in English. However as soon as we get Thai characters (because the orders are in Thailand) Cf server kicks in and converts the the Formfield posted (location) into something like 'อำเภอ'.

If we create a test page and put a <cfprocessingdirective pageencoding="utf-8" > it is fine. But as the 3rd party will be creating the http post in another application(not Cf), we need to be able to force the http request to treat all Formfields as utf-8. And the problem is that either Cf9 or Taffy is not doing this by default.

Why I think this may be a Taffy issue (and therefore a question for Adam) in that this must surely have been noticed before by anyone using Cf9 and Taffy in an international context where some 3rd-party application is calling the published Taffy Api. Furthermore Taffy logs the http request arguments correctly: e.g. here is a part of the logged Api call clearly showing Thai charcters:

{"CFC":"ProductsKerry","VERB":"POST","MIMEEXT":"json","6":{"ACCESS":"public","OUTPUT":false},"REQUESTARGUMENTS":{"LOCATION":"กรุงเทพ","REF_NO":"DTACSTG0000026860","UPDATE_DATE":"2016-11-02 "Content-Type":"multipart\/form-data; boundary=----WebKitFormBoundarykKKttiAa95Fznylv","Accept":"*\/*","X-
...
'Original-URL":"\/api\/kerry\/dtacChangeOrderStatus"}}

(I've deliberately removed sensitive information)

So at the point of logging Taffy does know the correct character encoding but later on (but before passing request arguments on through to our back-end it doesn't).

Because, when we debug Taffy's api.cfc by dumping in the OnRequest function the Thai location has already been converted to

"%C3%A0%C2%B8%C2%AD%C3%A0%C2%B8%C2%B3%C3%A0%C2%B9%E2%82%AC%C3%A0%C2%B8%C2%A0%C3%A0%C2%B8%C2%AD"


which then gets URLDecoded() to a mangled:  'อำเภอ'.

Has anyone encountered this problem before (with or without Taffy), and if so, any ideas for solutions?

We have tried all suggestions found in Stackoverflow, and the only setting that helps in out Cf9 test environment is hard-wiring the cfprocessingdirective immedaitely before our test call.

Clearly we cannot ask the 3rd party to put a Cf server directive before making the api call!

Here is out test code:

<cfhttp url="#theTaffyUrl#" method="post" charset="utf-8" multipart="yes" >

<cfhttpparam type="HEADER" name="charset" value="utf-8">
<cfhttpparam type="HEADER" name="X-Custom-API-Key" value="***P9HOJB26JU***ARMHA***F4I2"/>

<cfhttpparam type="FORMFIELD"  name="con_no" value="#url.con_no#"/>
<cfhttpparam type="FORMFIELD"  name="status_code" value="101"/>
<cfhttpparam type="FORMFIELD"  name="status_desc" value="Delivered"/>
<cfhttpparam type="FORMFIELD"  name="status_date" value="#dateFormat(Now(),'YYYY-MM-DD')# #timeFormat(Now(),'HH:MM:SS')#"/>
<cfhttpparam type="FORMFIELD"  name="update_date" value="#dateFormat(Now(),'YYYY-MM-DD')# #timeFormat(Now(),'HH:MM:SS')#"/>
<cfhttpparam type="FORMFIELD"  name="ref_no" value="#url.orderRef#"/>
<cfhttpparam type="FORMFIELD"  name="location" value="อำเภอ"/>

</cfhttp>



All help appreciated,

Thanks guys

--
You received this message because you are subscribed to the Google Groups "Taffy Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to taffy-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages