diff options
author | rhenium <re4k@re4k.info> | 2013-06-02 17:52:13 +0900 |
---|---|---|
committer | rhenium <re4k@re4k.info> | 2013-06-02 17:52:13 +0900 |
commit | 95820bfb617b4c466f908ed6d5d68bf0b3da790b (patch) | |
tree | 77f9de82f60e1606345ffe3ad691f362abe3733d /app/helpers/application_helper.rb | |
parent | 6270a689cf85cf95819426ba4e5ee88712605a07 (diff) | |
download | aclog-95820bfb617b4c466f908ed6d5d68bf0b3da790b.tar.gz |
change ':' escaping
Diffstat (limited to 'app/helpers/application_helper.rb')
-rw-r--r-- | app/helpers/application_helper.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 483a624..64033e8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,3 +1,4 @@ +# -*- encoding: utf-8 -*- module ApplicationHelper def logged_in?; session[:user_id] && session[:account] end @@ -6,15 +7,14 @@ module ApplicationHelper end def format_tweet_text(text) - ret = text.gsub(/<([a-z]+?):(.+?)(?::(.+?))?>/) do + ret = text.gsub(/<([a-z]+?)(?<!\\):(.+?)(?:(?<!\\):(.+?))?>/) do case $1 when "mention" screen_name = CGI.unescape($2) link_to("@#{screen_name}", "/#{screen_name}") when "url" - display = CGI.unescape($3) - expanded_url = CGI.unescape($2) - link_to(display, expanded_url) + n = [$3, $2.gsub(/(https?)%3A/, "\\1:")].map {|m| m.gsub("\\:", ":") } + link_to(*n) when "hashtag" hashtag = CGI.unescape($2) link_to("##{hashtag}", "https://twitter.com/search?q=#{CGI.escape("##{hashtag}")}") |