Skip to content

Commit

Permalink
Quickfix for not valid UTF-8 strings in ConnectionStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeikemo committed Oct 26, 2010
1 parent ae33dda commit f9f9baf
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions em/ConnectionStorage.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
require 'em-mongo'
require 'iconv'


IC = Iconv.new('UTF-8//IGNORE', 'UTF-8')
def clean_untrusted_string(str)
IC.iconv(str + ' ')[0..-2]
end


class ConnectionStorage

Expand Down Expand Up @@ -37,8 +45,8 @@ def message(body,tadpole)
@messages.insert( {
:created_on => Time.now,
:connection_id => @doc["_id"].to_s,
:body => body,
:author => tadpole.handle,
:body => clean_untrusted_string(body),
:author => clean_untrusted_string(tadpole.handle),
:location => [tadpole.pos.x,tadpole.pos.y]
})
end
Expand Down

0 comments on commit f9f9baf

Please sign in to comment.