Defect #1591 » urls_fix.patch
| lib/redcloth.rb Mon Aug 25 18:35:20 2008 +0200 → lib/redcloth.rb Tue Aug 26 12:02:05 2008 +0200 | ||
|---|---|---|
|
":
|
||
|
([\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]
|
||
| ... | ... | |
|
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
|
||
| lib/redmine/wiki_formatting.rb Mon Aug 25 18:35:20 2008 +0200 → lib/redmine/wiki_formatting.rb Tue Aug 26 12:02:05 2008 +0200 | ||
|---|---|---|
|
(\S+?) # url
|
||
|
(\/)? # slash
|
||
|
)
|
||
|
([^\w\=\/;]*?) # post
|
||
|
([^\w\=\/;\(\)]*?) # post
|
||
|
(?=<|\s|$)
|
||
|
}x unless const_defined?(:AUTO_LINK_RE)
|
||
| ... | ... | |
|
# 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
|
||
| test/unit/helpers/application_helper_test.rb Mon Aug 25 18:35:20 2008 +0200 → test/unit/helpers/application_helper_test.rb Tue Aug 26 12:02:05 2008 +0200 | ||
|---|---|---|
|
'This is a link: http://foo.bar.' => 'This is a link: <a class="external" href="http://foo.bar">http://foo.bar</a>.',
|
||
|
'A link (eg. http://foo.bar).' => 'A link (eg. <a class="external" href="http://foo.bar">http://foo.bar</a>).',
|
||
|
'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>.',
|
||
|
'http://www.foo.bar/Test_(foobar)' => '<a class="external" href="http://www.foo.bar/Test_(foobar)">http://www.foo.bar/Test_(foobar)</a>',
|
||
|
'(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>)',
|
||
|
'(see "inline link":http://www.foo.bar/Test_(foobar))' => '(see <a href="http://www.foo.bar/Test_(foobar)" class="external">inline link</a>)',
|
||
|
'www.foo.bar' => '<a class="external" href="http://www.foo.bar">www.foo.bar</a>',
|
||
|
'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>',
|
||
|
'http://foo.bar/page#125' => '<a class="external" href="http://foo.bar/page#125">http://foo.bar/page#125</a>',
|
||
|
'http://foo@www.bar.com' => '<a class="external" href="http://foo@www.bar.com">http://foo@www.bar.com</a>',
|
||
|
'http://foo:bar@www.bar.com' => '<a class="external" href="http://foo:bar@www.bar.com">http://foo:bar@www.bar.com</a>',
|
||
|
'ftp://foo.bar' => '<a class="external" href="ftp://foo.bar">ftp://foo.bar</a>',
|
||
|
}
|
||
|
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
|
||
- « Previous
- 1
- 2
- Next »