@@ -788,10 +788,10 class RedCloth3 < String | |||
|
788 | 788 | ": |
|
789 | 789 | ([\w\/]\S+?) # $url |
|
790 | 790 | (\/)? # $slash |
|
791 |
([^\w\/;]*?) |
|
|
791 | ([^\w\=\/;\(\)]*?) # $post | |
|
792 | 792 | (?=<|\s|$) |
|
793 | 793 | /x |
|
794 | ||
|
794 | #" | |
|
795 | 795 | def inline_textile_link( text ) |
|
796 | 796 | text.gsub!( LINK_RE ) do |m| |
|
797 | 797 | pre,atts,text,title,url,slash,post = $~[1..7] |
@@ -799,6 +799,12 class RedCloth3 < String | |||
|
799 | 799 | url, url_title = check_refs( url ) |
|
800 | 800 | title ||= url_title |
|
801 | 801 | |
|
802 | # Idea below : an URL with unbalanced parethesis and | |
|
803 | # ending by ')' is put into external parenthesis | |
|
804 | if ( url[-1]==?) and ((url.count("(") - url.count(")")) < 0 ) ) | |
|
805 | url=url[0..-2] # discard closing parenth from url | |
|
806 | post = ")"+post # add closing parenth to post | |
|
807 | end | |
|
802 | 808 | atts = pba( atts ) |
|
803 | 809 | atts = " href=\"#{ url }#{ slash }\"#{ atts }" |
|
804 | 810 | atts << " title=\"#{ title }\"" if title |
@@ -144,7 +144,7 module Redmine | |||
|
144 | 144 | (\S+?) # url |
|
145 | 145 | (\/)? # slash |
|
146 | 146 | ) |
|
147 | ([^\w\=\/;]*?) # post | |
|
147 | ([^\w\=\/;\(\)]*?) # post | |
|
148 | 148 | (?=<|\s|$) |
|
149 | 149 | }x unless const_defined?(:AUTO_LINK_RE) |
|
150 | 150 | |
@@ -156,7 +156,13 module Redmine | |||
|
156 | 156 | # don't replace URL's that are already linked |
|
157 | 157 | # and URL's prefixed with ! !> !< != (textile images) |
|
158 | 158 | all |
|
159 |
else |
|
|
159 | else | |
|
160 | # Idea below : an URL with unbalanced parethesis and | |
|
161 | # ending by ')' is put into external parenthesis | |
|
162 | if ( url[-1]==?) and ((url.count("(") - url.count(")")) < 0 ) ) | |
|
163 | url=url[0..-2] # discard closing parenth from url | |
|
164 | post = ")"+post # add closing parenth to post | |
|
165 | end | |
|
160 | 166 | %(#{leading}<a class="external" href="#{proto=="www."?"http://www.":proto}#{url}">#{proto + url}</a>#{post}) |
|
161 | 167 | end |
|
162 | 168 | end |
@@ -38,10 +38,18 class ApplicationHelperTest < HelperTestCase | |||
|
38 | 38 | 'This is a link: http://foo.bar.' => 'This is a link: <a class="external" href="http://foo.bar">http://foo.bar</a>.', |
|
39 | 39 | 'A link (eg. http://foo.bar).' => 'A link (eg. <a class="external" href="http://foo.bar">http://foo.bar</a>).', |
|
40 | 40 | 'http://foo.bar/foo.bar#foo.bar.' => '<a class="external" href="http://foo.bar/foo.bar#foo.bar">http://foo.bar/foo.bar#foo.bar</a>.', |
|
41 | 'http://www.foo.bar/Test_(foobar)' => '<a class="external" href="http://www.foo.bar/Test_(foobar)">http://www.foo.bar/Test_(foobar)</a>', | |
|
42 | '(see inline link : http://www.foo.bar/Test_(foobar))' => '(see inline link : <a class="external" href="http://www.foo.bar/Test_(foobar)">http://www.foo.bar/Test_(foobar)</a>)', | |
|
43 | '(see inline link : http://www.foo.bar/Test)' => '(see inline link : <a class="external" href="http://www.foo.bar/Test">http://www.foo.bar/Test</a>)', | |
|
44 | '(see inline link : http://www.foo.bar/Test).' => '(see inline link : <a class="external" href="http://www.foo.bar/Test">http://www.foo.bar/Test</a>).', | |
|
45 | '(see "inline link":http://www.foo.bar/Test_(foobar))' => '(see <a href="http://www.foo.bar/Test_(foobar)" class="external">inline link</a>)', | |
|
46 | '(see "inline link":http://www.foo.bar/Test)' => '(see <a href="http://www.foo.bar/Test" class="external">inline link</a>)', | |
|
47 | '(see "inline link":http://www.foo.bar/Test).' => '(see <a href="http://www.foo.bar/Test" class="external">inline link</a>).', | |
|
41 | 48 | 'www.foo.bar' => '<a class="external" href="http://www.foo.bar">www.foo.bar</a>', |
|
42 | 49 | 'http://foo.bar/page?p=1&t=z&s=' => '<a class="external" href="http://foo.bar/page?p=1&t=z&s=">http://foo.bar/page?p=1&t=z&s=</a>', |
|
43 | 50 | 'http://foo.bar/page#125' => '<a class="external" href="http://foo.bar/page#125">http://foo.bar/page#125</a>', |
|
44 | 51 | 'http://foo@www.bar.com' => '<a class="external" href="http://foo@www.bar.com">http://foo@www.bar.com</a>', |
|
52 | 'http://foo:bar@www.bar.com' => '<a class="external" href="http://foo:bar@www.bar.com">http://foo:bar@www.bar.com</a>', | |
|
45 | 53 | 'ftp://foo.bar' => '<a class="external" href="ftp://foo.bar">ftp://foo.bar</a>', |
|
46 | 54 | } |
|
47 | 55 | to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) } |
General Comments 0
You need to be logged in to leave comments.
Login now