ufront / ufront-mvc

The core MVC framework that powers ufront
MIT License
17 stars 15 forks source link

Remoting from js to php fail : Bad string length #26

Closed memilian closed 9 years ago

memilian commented 9 years ago

when using remoting to send an api call, if a parameter is a string that contains special character or spaces, the unserialization fail on the server. The problem is that client side the string is serialized after a call to encodeURIComponent and server-side, the HttpRequest.get_post method perform urldecode() on the post string, causing the string length mismatch when the unserializer run.

memilian commented 9 years ago

In fact the problem is not directly caused by the get_post method but by getHashFromString. A workaround is to replace line 305 in HttpRequest by paramPattern.matched(1) == "__x" ? paramPattern.matched(2) : StringTools.urlDecode(paramPattern.matched(2)));

jasononeil commented 9 years ago

Sorry for the late reply, I didn't see this message come through :(

Thanks for the bug report - it looks like you're correct about the cause of the problem. I'll investigate in the coming days.

(On a side note: Currently the unit tests don't cover end-to-end remoting, and I usually use Neko in my more complex projects, so it is easy for bugs to slip through. I'll have to try add some automated tests for this with PHP.)