summaryrefslogtreecommitdiffstats
path: root/lib/redmine/wiki_formatting.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-09-30 15:16:58 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-09-30 15:16:58 +0000
commitb4d66593ef6ed7b0d260cece6ffc41874b077cea (patch)
tree37764dd380994d7d243c70d1d84d95eec9e9a432 /lib/redmine/wiki_formatting.rb
parentcae547a7ea519aa2519053e366aecba378e787c6 (diff)
downloadredmine-b4d66593ef6ed7b0d260cece6ffc41874b077cea.tar.gz
redmine-b4d66593ef6ed7b0d260cece6ffc41874b077cea.zip
Fixed: Links get chopped by punctuation marks in anchors.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@775 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/wiki_formatting.rb')
-rw-r--r--lib/redmine/wiki_formatting.rb24
1 files changed, 10 insertions, 14 deletions
diff --git a/lib/redmine/wiki_formatting.rb b/lib/redmine/wiki_formatting.rb
index 623f2491f..dc296547d 100644
--- a/lib/redmine/wiki_formatting.rb
+++ b/lib/redmine/wiki_formatting.rb
@@ -1,6 +1,6 @@
require 'redcloth'
require 'coderay'
-
+require 'pp'
module Redmine
module WikiFormatting
@@ -79,29 +79,25 @@ module Redmine
(
(?:https?://)| # protocol spec, or
(?:www\.) # www.*
- )
+ )
(
- [-\w]+ # subdomain or domain
- (?:\.[-\w]+)* # remaining subdomains or domain
- (?::\d+)? # port
- (?:/(?:(?:[~\w\+%-]|(?:[,.;:][^\s$]))+)?)* # path
- (?:\?[\w\+%&=.;-]+)? # query string
- (?:\#[\w\-]*)? # trailing anchor
+ (\S+?) # url
+ (\/)? # slash
)
- ([[:punct:]]|\s|<|$) # trailing text
+ ([^\w\=\/;]*?) # post
+ (?=<|\s|$)
}x unless const_defined?(:AUTO_LINK_RE)
# Turns all urls into clickable links (code from Rails).
def inline_auto_link(text)
text.gsub!(AUTO_LINK_RE) do
- all, a, b, c, d = $&, $1, $2, $3, $4
- if a =~ /<a\s/i || a =~ /![<>=]?/
+ all, leading, proto, url, post = $&, $1, $2, $3, $6
+ if leading =~ /<a\s/i || leading =~ /![<>=]?/
# don't replace URL's that are already linked
# and URL's prefixed with ! !> !< != (textile images)
all
- else
- text = b + c
- %(#{a}<a href="#{b=="www."?"http://www.":b}#{c}">#{text}</a>#{d})
+ else
+ %(#{leading}<a href="#{proto=="www."?"http://www.":proto}#{url}">#{proto + url}</a>#{post})
end
end
end