rails_autolink 1.0.9 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -10,8 +10,8 @@ bridge the gap for people migrating.
10
10
 
11
11
  == FEATURES:
12
12
 
13
- By default auto_link returns sanitized html_safe strings.
14
- This behaviour can be overriden setting the <tt>:sanitize</tt> option to false
13
+ By default auto_link returns sanitized html_safe strings.
14
+ This behaviour can be overriden setting the <tt>:sanitize</tt> option to false
15
15
  (thus making it insecure if you don't have the content under control).
16
16
 
17
17
  == SYNOPSIS:
@@ -21,20 +21,20 @@ This behaviour can be overriden setting the <tt>:sanitize</tt> option to false
21
21
  auto_link("Go to http://www.rubyonrails.org and say hello to david@loudthinking.com")
22
22
  # => "Go to <a href=\"http://www.rubyonrails.org\">http://www.rubyonrails.org</a> and
23
23
  # say hello to <a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a>"
24
-
24
+
25
25
  auto_link("Visit http://www.loudthinking.com/ or e-mail david@loudthinking.com", :link => :urls)
26
26
  # => "Visit <a href=\"http://www.loudthinking.com/\">http://www.loudthinking.com/</a>
27
27
  # or e-mail david@loudthinking.com"
28
-
28
+
29
29
  auto_link("Visit http://www.loudthinking.com/ or e-mail david@loudthinking.com", :link => :email_addresses)
30
30
  # => "Visit http://www.loudthinking.com/ or e-mail <a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a>"
31
-
31
+
32
32
  auto_link("Go to http://www.rubyonrails.org <script>Malicious code!</script>")
33
33
  # => "Go to <a href=\"http://www.rubyonrails.org\">http://www.rubyonrails.org</a> "
34
-
34
+
35
35
  auto_link("Go to http://www.rubyonrails.org <script>alert('Script!')</script>", :sanitize => false)
36
36
  # => "Go to <a href=\"http://www.rubyonrails.org\">http://www.rubyonrails.org</a> <script>alert('Script!')</script>"
37
-
37
+
38
38
  post_body = "Welcome to my new blog at http://www.myblog.com/. Please e-mail me at me@email.com."
39
39
  auto_link(post_body, :html => { :target => '_blank' }) do |text|
40
40
  truncate(text, :length => 15)
@@ -43,7 +43,7 @@ This behaviour can be overriden setting the <tt>:sanitize</tt> option to false
43
43
 
44
44
  == REQUIREMENTS:
45
45
 
46
- * rails ~> 3.1
46
+ * rails > 3.1
47
47
 
48
48
  == INSTALL:
49
49
 
data/Rakefile CHANGED
@@ -1,21 +1,8 @@
1
- # -*- ruby -*-
1
+ # Setup some testing
2
+ require 'rake'
3
+ require 'rake/testtask'
2
4
 
3
- require 'rubygems'
4
- require 'hoe'
5
-
6
- Hoe.plugins.delete :rubyforge
7
- Hoe.plugin :minitest
8
- Hoe.plugin :gemspec # `gem install hoe-gemspec`
9
- Hoe.plugin :git # `gem install hoe-git`
10
-
11
- Hoe.spec 'rails_autolink' do
12
- developer('Aaron Patterson', 'aaron@tenderlovemaking.com')
13
- developer('Juanjo Bazan', 'jjbazan@gmail.com')
14
- developer('Akira Matsuda', 'ronnie@dio.jp')
15
- self.readme_file = 'README.rdoc'
16
- self.history_file = 'CHANGELOG.rdoc'
17
- self.extra_rdoc_files = FileList['*.rdoc']
18
- self.extra_deps << ['rails', '~> 3.1']
5
+ Rake::TestTask.new do |t|
6
+ t.libs << 'test'
7
+ t.pattern = 'test/test_*.rb'
19
8
  end
20
-
21
- # vim: syntax=ruby
@@ -1,5 +1,5 @@
1
1
  module RailsAutolink
2
- VERSION = '1.0.9'
2
+ VERSION = '1.1.0'
3
3
 
4
4
  class Railtie < ::Rails::Railtie
5
5
  initializer 'rails_autolink' do |app|
@@ -15,7 +15,7 @@ module RailsAutolink
15
15
  # <tt>:email_addresses</tt>, and <tt>:urls</tt>. If a block is given, each URL and
16
16
  # e-mail address is yielded and the result is used as the link text. By default the
17
17
  # text given is sanitized, you can override this behaviour setting the
18
- # <tt>:sanitize</tt> option to false, or you can add options to the sanitization of
18
+ # <tt>:sanitize</tt> option to false, or you can add options to the sanitization of
19
19
  # the text using the <tt>:sanitize_options</tt> option hash.
20
20
  #
21
21
  # ==== Examples
@@ -49,7 +49,7 @@ module RailsAutolink
49
49
  # auto_link(post_body, :all, :target => "_blank")
50
50
  # # => "Welcome to my new blog at <a href=\"http://www.myblog.com/\" target=\"_blank\">http://www.myblog.com</a>.
51
51
  # Please e-mail me at <a href=\"mailto:me@email.com\">me@email.com</a>."
52
- def auto_link(text, *args, &block)#link = :all, html = {}, &block)
52
+ def auto_link(text, *args, &block) #link = :all, html = {}, &block)
53
53
  return ''.html_safe if text.blank?
54
54
 
55
55
  options = args.size == 2 ? {} : args.extract_options! # this is necessary because the old auto_link API has a Hash as its last parameter
@@ -71,7 +71,7 @@ module RailsAutolink
71
71
  private
72
72
 
73
73
  AUTO_LINK_RE = %r{
74
- (?: ((?:ed2k|ftp|http|https|irc|mailto|news|gopher|nntp|telnet|webcal|xmpp|callto|feed|svn|urn|aim|rsync|tag|ssh|sftp|rtsp|afs):)// | www\. )
74
+ (?: ((?:ed2k|ftp|http|https|irc|mailto|news|gopher|nntp|telnet|webcal|xmpp|callto|feed|svn|urn|aim|rsync|tag|ssh|sftp|rtsp|afs|file):)// | www\. )
75
75
  [^\s<]+
76
76
  }x
77
77
 
@@ -0,0 +1,13 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'rails_autolink'
3
+ s.version = '1.1.0'
4
+ s.authors = ['Aaron Patterson', 'Juanjo Bazan', 'Akira Matsuda']
5
+ s.email = 'aaron@tenderlovemaking.com'
6
+ s.homepage = 'https://github.com/tenderlove/rails_autolink'
7
+ s.summary = 'Automatic generation of html links in texts'
8
+ s.summary = 'This is an extraction of the `auto_link` method from rails. The `auto_link` method was removed from Rails in version Rails 3.1. This gem is meant to bridge the gap for people migrating.'
9
+
10
+ s.add_dependency 'rails', '> 3.1'
11
+
12
+ s.files = Dir["#{File.dirname(__FILE__)}/**/*"]
13
+ end
@@ -88,17 +88,17 @@ class TestRailsAutolink < MiniTest::Unit::TestCase
88
88
  assert_equal %{<a href="http://www.rubyonrails.com?id=1&num=2">http://www.rubyonrails.com?id=1&num=2</a>}, auto_link("#{link_raw}#{malicious_script}")
89
89
  assert auto_link("#{link_raw}#{malicious_script}").html_safe?
90
90
  end
91
-
91
+
92
92
  def test_auto_link_should_sanitize_input_with_sanitize_options
93
93
  link_raw = %{http://www.rubyonrails.com?id=1&num=2}
94
94
  malicious_script = '<script>alert("malicious!")</script>'
95
95
  text_with_attributes = %{<a href="http://ruby-lang-org" target="_blank" data-malicious="inject">Ruby</a>}
96
-
96
+
97
97
  text_result = %{<a class="big" href="http://www.rubyonrails.com?id=1&num=2">http://www.rubyonrails.com?id=1&num=2</a><a href="http://ruby-lang-org" target="_blank">Ruby</a>}
98
98
  assert_equal text_result, auto_link("#{link_raw}#{malicious_script}#{text_with_attributes}",
99
99
  :sanitize_options => {:attributes => ["target", "href"]},
100
100
  :html => {:class => 'big'})
101
-
101
+
102
102
  assert auto_link("#{link_raw}#{malicious_script}#{text_with_attributes}",
103
103
  :sanitize_options => {:attributes => ["target", "href"]},
104
104
  :html => {:class => 'big'}).html_safe?
@@ -107,7 +107,7 @@ class TestRailsAutolink < MiniTest::Unit::TestCase
107
107
  def test_auto_link_should_not_sanitize_input_when_sanitize_option_is_false
108
108
  link_raw = %{http://www.rubyonrails.com?id=1&num=2}
109
109
  malicious_script = '<script>alert("malicious!")</script>'
110
-
110
+
111
111
  assert_equal %{<a href="http://www.rubyonrails.com?id=1&num=2">http://www.rubyonrails.com?id=1&num=2</a><script>alert("malicious!")</script>}, auto_link("#{link_raw}#{malicious_script}", :sanitize => false)
112
112
  assert !auto_link("#{link_raw}#{malicious_script}", :sanitize => false).html_safe?
113
113
  end
@@ -116,14 +116,8 @@ class TestRailsAutolink < MiniTest::Unit::TestCase
116
116
  ftp_raw = 'ftp://example.com/file.txt'
117
117
  assert_equal %(Download #{generate_result(ftp_raw)}), auto_link("Download #{ftp_raw}")
118
118
 
119
- file_scheme = 'file:///home/username/RomeoAndJuliet.pdf'
120
- z39_scheme = 'z39.50r://host:696/db'
121
- chrome_scheme = 'chrome://package/section/path'
122
- view_source = 'view-source:http://en.wikipedia.org/wiki/URI_scheme'
119
+ file_scheme = 'file:///home/username/RomeoAndJuliet.pdf'
123
120
  assert_equal generate_result(file_scheme), auto_link(file_scheme)
124
- assert_equal generate_result(z39_scheme), auto_link(z39_scheme)
125
- assert_equal generate_result(chrome_scheme), auto_link(chrome_scheme)
126
- assert_equal generate_result(view_source), auto_link(view_source)
127
121
  end
128
122
 
129
123
  def test_auto_link_already_linked
@@ -156,14 +150,14 @@ class TestRailsAutolink < MiniTest::Unit::TestCase
156
150
  email_raw = 'santiago@wyeworks.com'
157
151
  link_raw = 'http://www.rubyonrails.org'
158
152
  malicious_script = '<script>alert("malicious!")</script>'
159
-
153
+
160
154
  assert auto_link(nil).html_safe?, 'should be html safe'
161
155
  assert auto_link('').html_safe?, 'should be html safe'
162
156
  assert auto_link("#{link_raw} #{link_raw} #{link_raw}").html_safe?, 'should be html safe'
163
157
  assert auto_link("hello #{email_raw}").html_safe?, 'should be html safe'
164
158
  assert auto_link("hello #{email_raw} #{malicious_script}").html_safe?, 'should be html safe'
165
159
  end
166
-
160
+
167
161
  def test_auto_link_should_not_be_html_safe_when_sanitize_option_false
168
162
  email_raw = 'santiago@wyeworks.com'
169
163
  link_raw = 'http://www.rubyonrails.org'
@@ -204,11 +198,8 @@ class TestRailsAutolink < MiniTest::Unit::TestCase
204
198
  email2_raw = '+david@loudthinking.com'
205
199
  email2_result = %{<a href="mailto:#{email2_raw}">#{email2_raw}</a>}
206
200
  assert_equal email2_result, auto_link(email2_raw)
207
-
208
- email3_raw = '+david@loudthinking.com'
209
- email3_result = %{<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;+%64%61%76%69%64@%6c%6f%75%64%74%68%69%6e%6b%69%6e%67.%63%6f%6d">#{email3_raw}</a>}
210
- assert_equal email3_result, auto_link(email3_raw, :all, :encode => :hex)
211
- assert_equal email3_result, auto_link(email3_raw, :email_addresses, :encode => :hex)
201
+ assert_equal email2_result, auto_link(email2_raw, :all)
202
+ assert_equal email2_result, auto_link(email2_raw, :email_addresses)
212
203
 
213
204
  link2_raw = 'www.rubyonrails.com'
214
205
  link2_result = generate_result(link2_raw, "http://#{link2_raw}")
metadata CHANGED
@@ -1,129 +1,92 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rails_autolink
3
- version: !ruby/object:Gem::Version
4
- hash: 5
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 9
10
- version: 1.0.9
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Aaron Patterson
14
9
  - Juanjo Bazan
15
10
  - Akira Matsuda
16
11
  autorequire:
17
12
  bindir: bin
18
13
  cert_chain: []
19
-
20
- date: 2012-05-26 00:00:00 Z
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
14
+ date: 2013-05-02 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
23
17
  name: rails
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirement: !ruby/object:Gem::Requirement
26
19
  none: false
27
- requirements:
28
- - - ~>
29
- - !ruby/object:Gem::Version
30
- hash: 5
31
- segments:
32
- - 3
33
- - 1
34
- version: "3.1"
20
+ requirements:
21
+ - - '>'
22
+ - !ruby/object:Gem::Version
23
+ version: '3.1'
35
24
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: rdoc
39
- prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- hash: 19
46
- segments:
47
- - 3
48
- - 10
49
- version: "3.10"
50
- type: :development
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: hoe
54
25
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
26
+ version_requirements: !ruby/object:Gem::Requirement
56
27
  none: false
57
- requirements:
58
- - - ~>
59
- - !ruby/object:Gem::Version
60
- hash: 7
61
- segments:
62
- - 3
63
- - 0
64
- version: "3.0"
65
- type: :development
66
- version_requirements: *id003
67
- description: |-
68
- This is an extraction of the `auto_link` method from rails. The `auto_link`
69
- method was removed from Rails in version Rails 3.1. This gem is meant to
70
- bridge the gap for people migrating.
71
- email:
72
- - aaron@tenderlovemaking.com
73
- - jjbazan@gmail.com
74
- - ronnie@dio.jp
28
+ requirements:
29
+ - - '>'
30
+ - !ruby/object:Gem::Version
31
+ version: '3.1'
32
+ description:
33
+ email: aaron@tenderlovemaking.com
75
34
  executables: []
76
-
77
35
  extensions: []
78
-
79
- extra_rdoc_files:
80
- - CHANGELOG.rdoc
81
- - Manifest.txt
82
- - README.rdoc
83
- files:
84
- - .autotest
85
- - CHANGELOG.rdoc
86
- - Gemfile
87
- - Manifest.txt
88
- - README.rdoc
89
- - Rakefile
90
- - lib/rails_autolink.rb
91
- - lib/rails_autolink/helpers.rb
92
- - test/test_rails_autolink.rb
93
- - .gemtest
94
- homepage: http://github.com/tenderlove/rails_autolink
36
+ extra_rdoc_files: []
37
+ files:
38
+ - ./CHANGELOG.rdoc
39
+ - ./Gemfile
40
+ - ./Gemfile.lock
41
+ - ./lib/rails_autolink/helpers.rb
42
+ - ./lib/rails_autolink.rb
43
+ - ./OLDGEMS/howto_release.txt
44
+ - ./OLDGEMS/rails_autolink-1.0.5/CHANGELOG.rdoc
45
+ - ./OLDGEMS/rails_autolink-1.0.5/Gemfile
46
+ - ./OLDGEMS/rails_autolink-1.0.5/lib/rails_autolink/helpers.rb
47
+ - ./OLDGEMS/rails_autolink-1.0.5/lib/rails_autolink.rb
48
+ - ./OLDGEMS/rails_autolink-1.0.5/Manifest.txt
49
+ - ./OLDGEMS/rails_autolink-1.0.5/Rakefile
50
+ - ./OLDGEMS/rails_autolink-1.0.5/README.rdoc
51
+ - ./OLDGEMS/rails_autolink-1.0.5/test/test_rails_autolink.rb
52
+ - ./OLDGEMS/rails_autolink-1.0.5.gem
53
+ - ./OLDGEMS/rails_autolink-1.0.7/CHANGELOG.rdoc
54
+ - ./OLDGEMS/rails_autolink-1.0.7/Gemfile
55
+ - ./OLDGEMS/rails_autolink-1.0.7/lib/rails_autolink/helpers.rb
56
+ - ./OLDGEMS/rails_autolink-1.0.7/lib/rails_autolink.rb
57
+ - ./OLDGEMS/rails_autolink-1.0.7/Manifest.txt
58
+ - ./OLDGEMS/rails_autolink-1.0.7/Rakefile
59
+ - ./OLDGEMS/rails_autolink-1.0.7/README.rdoc
60
+ - ./OLDGEMS/rails_autolink-1.0.7/test/test_rails_autolink.rb
61
+ - ./OLDGEMS/rails_autolink-1.0.7.gem
62
+ - ./rails_autolink.gemspec
63
+ - ./Rakefile
64
+ - ./README.rdoc
65
+ - ./test/test_rails_autolink.rb
66
+ homepage: https://github.com/tenderlove/rails_autolink
95
67
  licenses: []
96
-
97
68
  post_install_message:
98
- rdoc_options:
99
- - --main
100
- - README.rdoc
101
- require_paths:
69
+ rdoc_options: []
70
+ require_paths:
102
71
  - lib
103
- required_ruby_version: !ruby/object:Gem::Requirement
72
+ required_ruby_version: !ruby/object:Gem::Requirement
104
73
  none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- hash: 3
109
- segments:
110
- - 0
111
- version: "0"
112
- required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
79
  none: false
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- hash: 3
118
- segments:
119
- - 0
120
- version: "0"
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
121
84
  requirements: []
122
-
123
- rubyforge_project: rails_autolink
124
- rubygems_version: 1.8.24
85
+ rubyforge_project:
86
+ rubygems_version: 1.8.25
125
87
  signing_key:
126
88
  specification_version: 3
127
- summary: This is an extraction of the `auto_link` method from rails
128
- test_files:
129
- - test/test_rails_autolink.rb
89
+ summary: This is an extraction of the `auto_link` method from rails. The `auto_link`
90
+ method was removed from Rails in version Rails 3.1. This gem is meant to bridge
91
+ the gap for people migrating.
92
+ test_files: []
data/.autotest DELETED
@@ -1,8 +0,0 @@
1
- # -*- ruby -*-
2
-
3
- require 'autotest/restart'
4
-
5
- Autotest.add_hook :initialize do |at|
6
- at.testlib = 'minitest/autorun'
7
- at.find_directories = ARGV unless ARGV.empty?
8
- end
data/.gemtest DELETED
File without changes