From 424d84661a7049d1b76dcbada59021d54bf95f2e Mon Sep 17 00:00:00 2001 From: Toks Date: Mon, 10 Mar 2014 22:34:22 -0400 Subject: [PATCH] fixes #2105 Also fix bug where sources were not escaped at all on post versions page --- app/helpers/application_helper.rb | 4 +++- app/helpers/posts_helper.rb | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ac05ecbaa..acfcc1d88 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,6 +1,8 @@ module ApplicationHelper def wordbreakify(string) - raw(string.gsub(/(.{10})/, "\\1")) + lines = string.scan(/.{1,10}/) + wordbreaked_string = lines.map{|str| h(str)}.join("") + raw(wordbreaked_string) end def nav_link_to(text, url, options = nil) diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index 5c753f7f3..a37e8de32 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -19,11 +19,11 @@ module PostsHelper def post_source_tag(post) if post.source =~ %r!http://img\d+\.pixiv\.net/img/([^\/]+)/! - text = "pixiv/#{wordbreakify($1)}" + text = "pixiv/#{wordbreakify($1)}".html_safe source_link = link_to(text, post.normalized_source) source_search = "source:#{text}/" elsif post.source =~ %r!http://i\d\.pixiv\.net/img\d+/img/([^\/]+)/! - text = "pixiv/#{wordbreakify($1)}" + text = "pixiv/#{wordbreakify($1)}".html_safe source_link = link_to(text, post.normalized_source) source_search = "source:#{text}/" elsif post.source =~ %r{\Ahttps?://}