From 319863a7edb20d2581fb9180bfcd68a640586291 Mon Sep 17 00:00:00 2001 From: Patrick-Emil Zoerner Date: Fri, 10 Jun 2011 20:05:40 +0200 Subject: [PATCH] fixed regex to non greedy. Therefore no strip needed. --- app/helpers/markdownify_helper.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/helpers/markdownify_helper.rb b/app/helpers/markdownify_helper.rb index e9af64fb1..3eb8783fa 100644 --- a/app/helpers/markdownify_helper.rb +++ b/app/helpers/markdownify_helper.rb @@ -22,11 +22,11 @@ module MarkdownifyHelper end def process_links(message) - message.gsub!(/\[\s*([^\[]+)\s*\]\(\s*([^ ]+\s*) \"(([^&]|(&[^q])|(&q[^u])|(&qu[^o])|(&quo[^t])|("[^;]))+)\"\s*\)/) do |m| + message.gsub!(/\[\s*([^\[]+?)\s*\]\(\s*([^ ]+\s*) \"(([^&]|(&[^q])|(&q[^u])|(&qu[^o])|(&quo[^t])|("[^;]))+)\"\s*\)/) do |m| escape = "\\" - link = $1.strip - url = $2.strip - title = $3.strip + link = $1 + url = $2 + title = $3 url.gsub!("_", "\\_") url.gsub!("*", "\\*") protocol = (url =~ /^\w+:\/\//) ? '' :'http://' @@ -34,10 +34,10 @@ module MarkdownifyHelper res end - message.gsub!(/\[\s*([^\[]+)\s*\]\(\s*([^ ]+)\s*\)/) do |m| + message.gsub!(/\[\s*([^\[]+?)\s*\]\(\s*([^ ]+)\s*\)/) do |m| escape = "\\" - link = $1.strip - url = $2.strip + link = $1 + url = $2 url.gsub!("_", "\\_") url.gsub!("*", "\\*") protocol = (url =~ /^\w+:\/\//) ? '' :'http://'