From ff21c827e41e242b03e7bf59d0320b45ad610f68 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 2 Nov 2010 12:14:12 -0700 Subject: [PATCH] Revert "Merge remote branch 'ed0h/336-markdown-for-status-messages'" This reverts commit 2b128d88ec690a1569220ff1a5a5968ff095c850, reversing changes made to 8778bdab3b5dacdff98efb91abf051167ac0644a. --- app/helpers/status_messages_helper.rb | 40 ++------------- spec/helpers/status_messages_helper_spec.rb | 54 --------------------- 2 files changed, 5 insertions(+), 89 deletions(-) diff --git a/app/helpers/status_messages_helper.rb b/app/helpers/status_messages_helper.rb index b999f1a49..2e010715a 100644 --- a/app/helpers/status_messages_helper.rb +++ b/app/helpers/status_messages_helper.rb @@ -18,44 +18,14 @@ module StatusMessagesHelper # next line is important due to XSS! (h is rail's make_html_safe-function) message = h(message).html_safe - - message.gsub!(/\[([^\[]+)\]\(([^ ]+) \"(([^&]|(&[^q])|(&q[^u])|(&qu[^o])|(&quo[^t])|("[^;]))+)\"\)/, '\1') - message.gsub!(/\[([^\[]+)\]\(([^ ]+)\)/, '\1') - - message.gsub!(/( |^)(www\.[^ ]+\.[^ ])/) do |m| - res = "#{$1}http://#{$2}" - res.gsub!(/^(\*|_)$/) { |m| "\\#{$1}" } - res - end - message.gsub!(/( |^)http:\/\/www\.youtube\.com\/watch[^ ]*v=([A-Za-z0-9_]+)(&[^ ]*|)/) do |m| - res = "#{$1}youtube.com::#{$2}" - res.gsub!(/(\*|_)/) { |m| "\\#{$1}" } - res - end - message.gsub!(/(#{$3}} - res.gsub!(/(\*|_)/) { |m| "\\#{$1}" } - res - end - end - - message.gsub!(/([^\\]|^)\*\*(([^*]|([^*]\*[^*]))*[^*\\])\*\*/, '\1\2') - message.gsub!(/([^\\]|^)__(([^_]|([^_]_[^_]))*[^_\\])__/, '\1\2') - message.gsub!(/([^\\]|^)\*([^*]*[^\\])\*/, '\1\2') - message.gsub!(/([^\\]|^)_([^_]*[^\\])_/, '\1\2') - message.gsub!(/([^\\]|^)\*/, '\1') - message.gsub!(/([^\\]|^)_/, '\1') - message.gsub!("\\*", "*") - message.gsub!("\\_", "_") - - while youtube = message.match(/youtube\.com::([A-Za-z0-9_\\]+)/) + message.gsub!(/( |^)(www\.[^ ]+\.[^ ])/, '\1http://\2') + message.gsub!(/( |^)http:\/\/www\.youtube\.com\/watch[^ ]*v=([A-Za-z0-9_]+)(&[^ ]*|)/, '\1youtube.com::\2') + message.gsub!(/(https|http|ftp):\/\/([^ ]+)/, '\2') + + while youtube = message.match(/youtube\.com::([A-Za-z0-9_]+)/) videoid = youtube[1] message.gsub!('youtube.com::'+videoid, 'Youtube: ' + youtube_title(videoid) + '') end - return message end diff --git a/spec/helpers/status_messages_helper_spec.rb b/spec/helpers/status_messages_helper_spec.rb index 61ae88be0..0aee3826a 100644 --- a/spec/helpers/status_messages_helper_spec.rb +++ b/spec/helpers/status_messages_helper_spec.rb @@ -68,59 +68,5 @@ describe StatusMessagesHelper do make_links(url).should == ""+url+"" end - describe "markdown" do - describe "weak emphasis" do - it "should be recognized (1/2)" do - message = "*some text* some text *some text* some text" - make_links(message).should == "some text some text some text some text" - end - - it "should be recognized (2/2)" do - message = "_some text_ some text _some text_ some text" - make_links(message).should == "some text some text some text some text" - end - end - - describe "strong emphasis" do - it "should be recognized (1/2)" do - message = "**some text** some text **some text** some text" - make_links(message).should == "some text some text some text some text" - end - - it "should be recognized (2/2)" do - message = "__some text__ some text __some text__ some text" - make_links(message).should == "some text some text some text some text" - end - end - - describe "imbricated weak and strong emphasis" do - it "should be rendered correctly" do - message = "__this is _some_ text__" - make_links(message).should == "this is some text" - message = "*this is **some** text*" - make_links(message).should == "this is some text" - message = "___some text___" - make_links(message).should == "some text" - end - end - - describe "links" do - it "should be recognized without title attribute" do - message = "[link text](http://someurl.com) [link text](http://someurl.com)" - make_links(message).should == 'link text link text' - end - - it "should be recognized with title attribute" do - message = '[link text](http://someurl.com "some title") [link text](http://someurl.com "some title")' - make_links(message).should == 'link text link text' - end - end - - it "should allow escaping" do - message = '*some text* \\*some text* \\**some text* _some text_ \\_some text_ \\__some text_' - make_links(message).should == "some text *some text *some text some text _some text _some text" - end - end - end