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 | require "json" | 1 | require "json" |
2 | +require 'iconv' | ||
2 | 3 | ||
3 | module Twurl | 4 | module Twurl |
4 | class RequestController < AbstractCommandController | 5 | class RequestController < AbstractCommandController |
@@ -18,10 +19,12 @@ module Twurl | @@ -18,10 +19,12 @@ module Twurl | ||
18 | #unless chunk.to_i.length = 0 | 19 | #unless chunk.to_i.length = 0 |
19 | begin | 20 | begin |
20 | parsed = JSON.parse(chunk) | 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 | comment = Comment.new | 25 | comment = Comment.new |
23 | comment.source_id = Stream.page.id | 26 | comment.source_id = Stream.page.id |
24 | - comment.body = parsed["text"] | 27 | + comment.body = comment_text |
25 | comment.author_id = Stream.author_id | 28 | comment.author_id = Stream.author_id |
26 | comment.save! | 29 | comment.save! |
27 | rescue | 30 | rescue |