Search code examples
ruby-on-railsswfobjectuploadifyswfupload

Passing params from swfupload/uploadify to Rails app - broken?


I have an uploadify component, which sends the files back to rails application. The problem I noticed at some point is, that for some special values data passed along are altered by the flash object.

On the client side I have

 $(document).ready(function() {
   $('#photo_image').uploadify({
    ...
    'scriptData': {
       authenticity_token = 'M++Q3HNclKS7QBEM71lkF/8IkjTwr2JdtqJ4WNXVDro='
     ...
     }
   });
 });

What Rails is getting:

"authenticity_token"=>"M  Q3HNclKS7QBEM71lkF/8IkjTwr2JdtqJ4WNXVDro="

When there is no '+' sign in the token everything works just fine. It looks like the flash is altering the string somehow. Any idea how to escape it? I tried CGI.escape, but result is exactly the same, '+' are stripped...


Solution

  • Actual solution is, to escape the token twice. So for example "encodeURIComponent(encodeURIComponent(token)))" or #{u u token}.