Permalink
Browse files

Merge [5704], [6005], [6034] from trunk. References #7268, #7354.

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@6035 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent c9ed2f6 commit 553c23df82aef0b105944e7be9ef22be02a66a33 @jeremy jeremy committed Jan 24, 2007
View
@@ -1,3 +1,12 @@
+*SVN*
+
+* Autolinking recognizes trailing and embedded . , : ; #7354 [Jarkko Laine]
+
+* Make TextHelper::auto_link recognize URLs with colons in path correctly, fixes #7268. [imajes]
+
+* Improved auto_link to match more valid urls correctly [Tobias Luetke]
+
+
*1.13.1* (January 18th, 2007)
* Fixed content-type bug in Prototype [sam]
@@ -354,26 +354,26 @@ def set_cycle(name, cycle_object)
@_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\+%-]|(?:[,.;:][^\s$]))+)?)* # 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
@@ -130,7 +130,9 @@ def test_auto_link_parsing
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)
@@ -151,6 +153,14 @@ def test_auto_linking
link4_result = %{<a href="#{link4_raw}">#{link4_raw}</a>}
link5_raw = 'http://foo.example.com:3000/controller/action'
link5_result = %{<a href="#{link5_raw}">#{link5_raw}</a>}
+ link6_raw = 'http://foo.example.com:3000/controller/action+pack'
+ link6_result = %{<a href="#{link6_raw}">#{link6_raw}</a>}
+ link7_raw = 'http://foo.example.com/controller/action?parm=value&p2=v2#anchor-123'
+ link7_result = %{<a href="#{link7_raw}">#{link7_raw}</a>}
+ link8_raw = 'http://foo.example.com:3000/controller/action.html'
+ link8_result = %{<a href="#{link8_raw}">#{link8_raw}</a>}
+ link9_raw = 'http://business.timesonline.co.uk/article/0,,9065-2473189,00.html'
+ link9_result = %{<a href="#{link9_raw}">#{link9_raw}</a>}
assert_equal %(hello #{email_result}), auto_link("hello #{email_raw}", :email_addresses)
assert_equal %(Go to #{link_result}), auto_link("Go to #{link_raw}", :urls)
@@ -176,6 +186,20 @@ def test_auto_linking
assert_equal %(<p>Link #{link4_result}</p>), auto_link("<p>Link #{link4_raw}</p>")
assert_equal %(<p>#{link4_result} Link</p>), auto_link("<p>#{link4_raw} Link</p>")
assert_equal %(<p>#{link5_result} Link</p>), auto_link("<p>#{link5_raw} Link</p>")
+ assert_equal %(<p>#{link6_result} Link</p>), auto_link("<p>#{link6_raw} Link</p>")
+ assert_equal %(<p>#{link7_result} Link</p>), auto_link("<p>#{link7_raw} Link</p>")
+ assert_equal %(Go to #{link8_result}), auto_link("Go to #{link8_raw}", :urls)
+ assert_equal %(Go to #{link8_raw}), auto_link("Go to #{link8_raw}", :email_addresses)
+ assert_equal %(<p>Link #{link8_result}</p>), auto_link("<p>Link #{link8_raw}</p>")
+ assert_equal %(<p>#{link8_result} Link</p>), auto_link("<p>#{link8_raw} Link</p>")
+ assert_equal %(Go to #{link8_result}.), auto_link(%(Go to #{link8_raw}.))
+ assert_equal %(<p>Go to #{link8_result}. seriously, #{link8_result}? i think I'll say hello to #{email_result}. instead.</p>), auto_link(%(<p>Go to #{link8_raw}. seriously, #{link8_raw}? i think I'll say hello to #{email_raw}. instead.</p>))
+ assert_equal %(Go to #{link9_result}), auto_link("Go to #{link9_raw}", :urls)
+ assert_equal %(Go to #{link9_raw}), auto_link("Go to #{link9_raw}", :email_addresses)
+ assert_equal %(<p>Link #{link9_result}</p>), auto_link("<p>Link #{link9_raw}</p>")
+ assert_equal %(<p>#{link9_result} Link</p>), auto_link("<p>#{link9_raw} Link</p>")
+ assert_equal %(Go to #{link9_result}.), auto_link(%(Go to #{link9_raw}.))
+ assert_equal %(<p>Go to #{link9_result}. seriously, #{link9_result}? i think I'll say hello to #{email_result}. instead.</p>), auto_link(%(<p>Go to #{link9_raw}. seriously, #{link9_raw}? i think I'll say hello to #{email_raw}. instead.</p>))
assert_equal '', auto_link(nil)
assert_equal '', auto_link('')
end

0 comments on commit 553c23d

Please sign in to comment.