Fixed: http links containing parentheses fail to reder correctly (#1591). Patch by Paul Rivier.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1871 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
+8
-2
@@ -788,10 +788,10 @@ class RedCloth3 < String
|
||||
":
|
||||
([\w\/]\S+?) # $url
|
||||
(\/)? # $slash
|
||||
([^\w\/;]*?) # $post
|
||||
([^\w\=\/;\(\)]*?) # $post
|
||||
(?=<|\s|$)
|
||||
/x
|
||||
|
||||
#"
|
||||
def inline_textile_link( text )
|
||||
text.gsub!( LINK_RE ) do |m|
|
||||
pre,atts,text,title,url,slash,post = $~[1..7]
|
||||
@@ -799,6 +799,12 @@ class RedCloth3 < String
|
||||
url, url_title = check_refs( url )
|
||||
title ||= url_title
|
||||
|
||||
# Idea below : an URL with unbalanced parethesis and
|
||||
# ending by ')' is put into external parenthesis
|
||||
if ( url[-1]==?) and ((url.count("(") - url.count(")")) < 0 ) )
|
||||
url=url[0..-2] # discard closing parenth from url
|
||||
post = ")"+post # add closing parenth to post
|
||||
end
|
||||
atts = pba( atts )
|
||||
atts = " href=\"#{ url }#{ slash }\"#{ atts }"
|
||||
atts << " title=\"#{ title }\"" if title
|
||||
|
||||
@@ -144,7 +144,7 @@ module Redmine
|
||||
(\S+?) # url
|
||||
(\/)? # slash
|
||||
)
|
||||
([^\w\=\/;]*?) # post
|
||||
([^\w\=\/;\(\)]*?) # post
|
||||
(?=<|\s|$)
|
||||
}x unless const_defined?(:AUTO_LINK_RE)
|
||||
|
||||
@@ -156,7 +156,13 @@ module Redmine
|
||||
# don't replace URL's that are already linked
|
||||
# and URL's prefixed with ! !> !< != (textile images)
|
||||
all
|
||||
else
|
||||
else
|
||||
# Idea below : an URL with unbalanced parethesis and
|
||||
# ending by ')' is put into external parenthesis
|
||||
if ( url[-1]==?) and ((url.count("(") - url.count(")")) < 0 ) )
|
||||
url=url[0..-2] # discard closing parenth from url
|
||||
post = ")"+post # add closing parenth to post
|
||||
end
|
||||
%(#{leading}<a class="external" href="#{proto=="www."?"http://www.":proto}#{url}">#{proto + url}</a>#{post})
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user