Commit 3851bf5ce2479abd8a9552035c6b9644e14b2490
1 parent
34835cc9
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
twitter input sanitizing
Showing
1 changed file
with
5 additions
and
2 deletions
Show diff stats
plugins/community_hub/tweeter_stream/lib/twurl/request_controller.rb
1 | 1 | require "json" |
2 | +require 'iconv' | |
2 | 3 | |
3 | 4 | module Twurl |
4 | 5 | class RequestController < AbstractCommandController |
... | ... | @@ -18,10 +19,12 @@ module Twurl |
18 | 19 | #unless chunk.to_i.length = 0 |
19 | 20 | begin |
20 | 21 | parsed = JSON.parse(chunk) |
21 | - print "@#{parsed["user"]["name"]} said: #{parsed["text"]} \n" | |
22 | + ic = Iconv.new('UTF-8//IGNORE', 'UTF-8') | |
23 | + comment_text = ic.iconv("@#{parsed["user"]["name"]} " + _('said:') + " #{parsed["text"]}" + ' ')[0..-2] | |
24 | + print "#{comment_text}\n" | |
22 | 25 | comment = Comment.new |
23 | 26 | comment.source_id = Stream.page.id |
24 | - comment.body = parsed["text"] | |
27 | + comment.body = comment_text | |
25 | 28 | comment.author_id = Stream.author_id |
26 | 29 | comment.save! |
27 | 30 | rescue | ... | ... |