Escape youtube titles

This commit is contained in:
Raphael 2011-01-17 15:25:15 -08:00
parent baac8199da
commit bd4efe8c2d
4 changed files with 4 additions and 4 deletions

View file

@ -259,7 +259,7 @@ module ApplicationHelper
while youtube = message.match(/youtube\.com::([A-Za-z0-9_\\\-]+)/) while youtube = message.match(/youtube\.com::([A-Za-z0-9_\\\-]+)/)
video_id = youtube[1] video_id = youtube[1]
if youtube_maps && youtube_maps[video_id] if youtube_maps && youtube_maps[video_id]
title = youtube_maps[video_id] title = h(CGI::unescape(youtube_maps[video_id]))
else else
title = I18n.t 'application.helper.video_title.unknown' title = I18n.t 'application.helper.video_title.unknown'
end end

View file

@ -15,7 +15,7 @@ module YoutubeTitles
return unless youtube_match return unless youtube_match
video_id = youtube_match[1] video_id = youtube_match[1]
unless self.youtube_titles[video_id] unless self.youtube_titles[video_id]
self.youtube_titles[video_id] = youtube_title_for(video_id) self.youtube_titles[video_id] = CGI::escape(youtube_title_for(video_id))
end end
end end
YOUTUBE_ID_REGEX = /youtube\.com.*?v=([A-Za-z0-9_\\\-]+)/ unless defined? YOUTUBE_ID_REGEX YOUTUBE_ID_REGEX = /youtube\.com.*?v=([A-Za-z0-9_\\\-]+)/ unless defined? YOUTUBE_ID_REGEX

View file

@ -262,7 +262,7 @@ describe Comment do
comment = user.build_comment url, :on => @message comment = user.build_comment url, :on => @message
comment.save! comment.save!
Comment.find(comment.id).youtube_titles.should == {video_id => expected_title} Comment.find(comment.id).youtube_titles.should == {video_id => CGI::escape(expected_title)}
end end
end end
end end

View file

@ -100,7 +100,7 @@ describe StatusMessage do
post = @user.build_post :status_message, :message => url, :to => @aspect.id post = @user.build_post :status_message, :message => url, :to => @aspect.id
post.save! post.save!
Post.find(post.id).youtube_titles.should == {video_id => expected_title} Post.find(post.id).youtube_titles.should == {video_id => CGI::escape(expected_title)}
end end
end end