gr_autolink 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,11 @@
1
+ === 1.0.9 / 2012-03-30
2
+
3
+ * adding patterns to match...now anything that's alphanum + period + 2 or more alphanum + / other stuff will match as a url. this will get some false positives "...yes/no", but at least the regex is still simple and will catch a lot of cases the old version did not.
4
+
5
+ === 1.0.8 / 2012-03-30
6
+
7
+ * handling escaping of href and link text
8
+
1
9
  === 1.0.7 / 2012-03-30
2
10
 
3
11
  * forking off into gr_autolink as it will behave differently from parent
data/lib/gr_autolink.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module GrAutolink
2
- VERSION = '1.0.8'
2
+ VERSION = '1.0.9'
3
3
 
4
4
  class Railtie < ::Rails::Railtie
5
5
  initializer 'gr_autolink' do |app|
@@ -80,7 +80,7 @@ module GrAutolink
80
80
  private
81
81
 
82
82
  AUTO_LINK_RE = %r{
83
- (?: ([0-9A-Za-z+.:-]+:)// | www\. )
83
+ (?: ([0-9A-Za-z+.:-]+:)// | www\. | [a-zA-Z0-9.]+\.[a-zA-Z0-9]{2,}\/)
84
84
  [^\s<>]+
85
85
  }x
86
86
 
@@ -149,7 +149,6 @@ class TestGrAutolink < MiniTest::Unit::TestCase
149
149
  assert_equal linked_email, auto_link(linked_email)
150
150
  end
151
151
 
152
-
153
152
  def test_auto_link_at_eol
154
153
  url1 = "http://api.rubyonrails.com/Foo.html"
155
154
  url2 = "http://www.ruby-doc.org/core/Bar.html"
@@ -157,7 +156,7 @@ class TestGrAutolink < MiniTest::Unit::TestCase
157
156
  assert_equal %(<p><a href="#{url1}">#{url1}</a><br /><a href="#{url2}">#{url2}</a><br /></p>), auto_link("<p>#{url1}<br />#{url2}<br /></p>")
158
157
  end
159
158
 
160
- def test_auto_link_should_be_html_safe
159
+ def test_auto_link_should_be_html_safe_with_sanitize
161
160
  email_raw = 'santiago@wyeworks.com'
162
161
  link_raw = 'http://www.rubyonrails.org'
163
162
  malicious_script = '<script>alert("malicious!")</script>'
@@ -303,6 +302,7 @@ class TestGrAutolink < MiniTest::Unit::TestCase
303
302
  http://connect.oraclecorp.com/search?search[q]=green+france&search[type]=Group
304
303
  http://of.openfoundry.org/projects/492/download#4th.Release.3
305
304
  http://maps.google.co.uk/maps?f=q&q=the+london+eye&ie=UTF8&ll=51.503373,-0.11939&spn=0.007052,0.012767&z=16&iwloc=A
305
+ bit.ly/asdf
306
306
  )
307
307
 
308
308
  urls.each do |url|
@@ -329,6 +329,9 @@ class TestGrAutolink < MiniTest::Unit::TestCase
329
329
  private
330
330
  def generate_result(link_text, href = nil)
331
331
  href ||= link_text
332
+ if href !~ /:\/\//
333
+ href = "http://#{href}"
334
+ end
332
335
  if !link_text.html_safe?
333
336
  %{<a href="#{CGI::escapeHTML href}">#{CGI::escapeHTML link_text}</a>}
334
337
  else
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gr_autolink
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -16,7 +16,7 @@ date: 2012-03-31 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rails
19
- requirement: &2156556080 !ruby/object:Gem::Requirement
19
+ requirement: &2165102560 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
22
  - - ~>
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: '3.1'
25
25
  type: :runtime
26
26
  prerelease: false
27
- version_requirements: *2156556080
27
+ version_requirements: *2165102560
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rdoc
30
- requirement: &2156555580 !ruby/object:Gem::Requirement
30
+ requirement: &2165101880 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ~>
@@ -35,10 +35,10 @@ dependencies:
35
35
  version: '3.10'
36
36
  type: :development
37
37
  prerelease: false
38
- version_requirements: *2156555580
38
+ version_requirements: *2165101880
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: hoe
41
- requirement: &2156554800 !ruby/object:Gem::Requirement
41
+ requirement: &2165101320 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
44
  - - ~>
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: '2.16'
47
47
  type: :development
48
48
  prerelease: false
49
- version_requirements: *2156554800
49
+ version_requirements: *2165101320
50
50
  description: ! "This is an adaptation of the extraction of the `auto_link` method
51
51
  from rails\nthat is the rails_autolink gem. The `auto_link`\nmethod was removed
52
52
  from Rails in version Rails 3.1. This gem is meant to\nbridge the gap for people