mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Make TextHelper::auto_link recognize URLs with colons in path correctly, fixes #7268
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6005 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
0f8ed48bf5
commit
8e82e29010
3 changed files with 19 additions and 15 deletions
|
@ -1,5 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Make TextHelper::auto_link recognize URLs with colons in path correctly, fixes #7268. [imajes]
|
||||
|
||||
* Update to script.aculo.us 1.7.0. [Thomas Fuchs]
|
||||
|
||||
* Modernize cookie testing code, and increase coverage (Heckle++) #7101 [Kevin Clark]
|
||||
|
|
|
@ -354,26 +354,26 @@ module ActionView
|
|||
@_cycles = Hash.new unless defined?(@_cycles)
|
||||
@_cycles[name] = cycle_object
|
||||
end
|
||||
|
||||
|
||||
AUTO_LINK_RE = %r{
|
||||
( # leading text
|
||||
<\w+.*?>| # leading HTML tag, or
|
||||
[^=!:'"/]| # leading punctuation, or
|
||||
^ # beginning of line
|
||||
( # leading text
|
||||
<\w+.*?>| # leading HTML tag, or
|
||||
[^=!:'"/]| # leading punctuation, or
|
||||
^ # beginning of line
|
||||
)
|
||||
(
|
||||
(?:https?://)| # protocol spec, or
|
||||
(?:www\.) # www.*
|
||||
(?:https?://)| # protocol spec, or
|
||||
(?:www\.) # www.*
|
||||
)
|
||||
(
|
||||
[-\w]+ # subdomain or domain
|
||||
(?:\.[-\w]+)* # remaining subdomains or domain
|
||||
(?::\d+)? # port
|
||||
(?:/(?:[~\w\+%.;-]+)?)* # path
|
||||
(?:\?[\w\+%&=.;-]+)? # query string
|
||||
(?:\#[\w\-]*)? # trailing anchor
|
||||
[-\w]+ # subdomain or domain
|
||||
(?:\.[-\w]+)* # remaining subdomains or domain
|
||||
(?::\d+)? # port
|
||||
(?:/(?:[~\w\+%.;:-]+)?)* # path
|
||||
(?:\?[\w\+%&=.;-]+)? # query string
|
||||
(?:\#[\w\-]*)? # trailing anchor
|
||||
)
|
||||
([[:punct:]]|\s|<|$) # trailing text
|
||||
([[:punct:]]|\s|<|$) # trailing text
|
||||
}x unless const_defined?(:AUTO_LINK_RE)
|
||||
|
||||
# Turns all urls into clickable links. If a block is given, each url
|
||||
|
|
|
@ -131,7 +131,9 @@ class TextHelperTest < Test::Unit::TestCase
|
|||
http://www.rubyonrails.com/contact;new
|
||||
http://www.rubyonrails.com/contact;new%20with%20spaces
|
||||
http://www.rubyonrails.com/contact;new?with=query&string=params
|
||||
http://www.rubyonrails.com/~minam/contact;new?with=query&string=params)
|
||||
http://www.rubyonrails.com/~minam/contact;new?with=query&string=params
|
||||
http://en.wikipedia.org/wiki/Wikipedia:Today%27s_featured_picture_%28animation%29/January_20%2C_2007
|
||||
)
|
||||
|
||||
urls.each do |url|
|
||||
assert_equal %(<a href="#{url}">#{url}</a>), auto_link(url)
|
||||
|
|
Loading…
Reference in a new issue