From 3851bf5ce2479abd8a9552035c6b9644e14b2490 Mon Sep 17 00:00:00 2001 From: Evandro Junior Date: Mon, 14 Apr 2014 17:50:07 +0000 Subject: [PATCH] twitter input sanitizing --- plugins/community_hub/tweeter_stream/lib/twurl/request_controller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/community_hub/tweeter_stream/lib/twurl/request_controller.rb b/plugins/community_hub/tweeter_stream/lib/twurl/request_controller.rb index f761183..d6b82a4 100755 --- a/plugins/community_hub/tweeter_stream/lib/twurl/request_controller.rb +++ b/plugins/community_hub/tweeter_stream/lib/twurl/request_controller.rb @@ -1,4 +1,5 @@ require "json" +require 'iconv' module Twurl class RequestController < AbstractCommandController @@ -18,10 +19,12 @@ module Twurl #unless chunk.to_i.length = 0 begin parsed = JSON.parse(chunk) - print "@#{parsed["user"]["name"]} said: #{parsed["text"]} \n" + ic = Iconv.new('UTF-8//IGNORE', 'UTF-8') + comment_text = ic.iconv("@#{parsed["user"]["name"]} " + _('said:') + " #{parsed["text"]}" + ' ')[0..-2] + print "#{comment_text}\n" comment = Comment.new comment.source_id = Stream.page.id - comment.body = parsed["text"] + comment.body = comment_text comment.author_id = Stream.author_id comment.save! rescue -- libgit2 0.21.2