]> git.openstreetmap.org Git - rails.git/commitdiff
Force encoding in AMF controller
authorTom Hughes <tom@compton.nu>
Wed, 31 Oct 2012 20:39:31 +0000 (20:39 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 31 Oct 2012 20:39:31 +0000 (20:39 +0000)
Although the strings are UTF-8 we need to treat them as byte
strings for the purposes of encoding AMF responses.

lib/potlatch.rb

index 919eb0122986fe5ac923e519c6a9aeb3934af713..35a60dfbb6b2d2757d7b2a24d29842e32077c4ec 100644 (file)
@@ -106,7 +106,8 @@ module Potlatch
     end
 
     # Encode string with two-byte length
-    def self.encodestring(n) 
+    def self.encodestring(n)
+      n=n.dup.force_encoding("ASCII-8BIT")
       a,b=n.size.divmod(256)
       a.chr+b.chr+n
     end