Creating a card with an image and a plus-card with a non-latin title fails

Support Ticket

+status
Creating a card with an image and a plus-card with a non-latin title fails+tags
 

Creating a card with an image and a plus-card with a non-latin title fails+issues

I have a custom cardtype "screenshot", which has a plus-card "+изображение" (Russian for "image") in it. Whenever I try to create a card of this type and attach an image, Wagn fails with an error 500 and the following log message:

  Parameters: {"utf8"=>"✓", "authenticity_token"=>"VKdqWKh5PeaXPlWCFbgmfulzwpzRW8WL/ZpTB9TFyRU=", "success"=>"REDIRECT: _self", "card"=>{"name"=>"Скриншот 1", "type_id"=>"882", "cards"=>{"~plus~\xD0\x9F\xD1\x80\xD0\xBE\xD0\xB5\xD0\xBA\xD1\x82"=>{"content"=>"Clients from hell", "type_id"=>"47"}, "~plus~\xD0\x98\xD0\xB7\xD0\xBE\xD0\xB1\xD1\x80\xD0\xB0\xD0\xB6\xD0\xB5\xD0\xBD\xD0\xB8\xD0\xB5"=>{"type_id"=>"19", "content"=>"CHOSEN", "attach"=>#>}}}, "pointer_item"=>"Clients from hell", "main"=>"", "is_main"=>"true", "slot"=>{"home_view"=>"new", "include"=>"_main", "include_name"=>"_main", "name_context"=>""}}
setting content for Скриншот 1: ()
Card(#<Card#914##40956720[no code:882](Скриншот 1){I:nil}>)#set_initial_content start 
setting content for Скриншот 1: (914)
set_initial_content

, , s.6737 #<Card#914##40956720[no code:882](Скриншот 1){I:nil}>
exception = Encoding::UndefinedConversionError: "\xD0" from ASCII-8BIT to UTF-8

When I try to create the card without uploading an image, it goes as expected:

  Parameters: {"utf8"=>"✓", "authenticity_token"=>"VKdqWKh5PeaXPlWCFbgmfulzwpzRW8WL/ZpTB9TFyRU=", "success"=>"REDIRECT: _self", "card"=>{"name"=>"1", "type_id"=>"882", "cards"=>{"~plus~Проект"=>{"content"=>"", "type_id"=>"47"}, "~plus~Изображение"=>{"type_id"=>"19"}}}, "pointer_item"=>"", "commit"=>"Submit", "main"=>"", "is_main"=>"true", "slot"=>{"home_view"=>"new", "include"=>"_main", "include_name"=>"_main", "name_context"=>""}}

It looks like having an image uploaded with a card triggers some kind of unicode escaping.

 

I was able to trace where the conversion is taking place and force UTF-8 on the string:

 

line 52 of smart_name.rb in smartname:

@s.force_encoding('UTF-8') if @s.match(".*?\\\xD0.*?")

 

It works, but it's an unreliable piece of ugly monkey patching; I have no actual knowledge of Ruby, so I can't really write a proper patch, sorry.

--Edward Medvedev.....2013-06-23 08:27:52 +0000

Thanks for the ticket, Edward. The thing we need to figure out is where the cyrillic unicode is getting misinterpreted as ASCII in the first place. Both the error message (Encoding::UndefinedConversionError: "\xD0" from ASCII-8BIT to UTF-8) and your fix suggest that the string was being interpreted as ASCII when it was clearly intended to be unicode from the start.

 

I haven't seen this, but I would investigate the webserver, the browser, and the database to see whether something is forcing ASCII interpretations before Wagn sees the code.

 

btw, this worked for me on a test instance

 

The problem with the force_encoding solution is that it *only* works when the character set has been misinterpreted in the first place. In general, ruby folks argue against using that method unless you *know* you're getting incorrectly encoded data. That works in your narrow case, but it's probably best to figure out where the incorrect encoding is coming from.

 

Let us know more about your setup and perhaps we can help.

 

Удачи!

--Ethan McCutchen.....2013-06-24 02:34:00 +0000