Skip to content

Commit e3fab78

Browse files
committed
removes tests for not supported features
1 parent e2ed924 commit e3fab78

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

test/test_rails_autolink.rb

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,17 @@ def test_auto_link_should_sanitize_input_when_sanitize_option_is_not_false
8888
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}")
8989
assert auto_link("#{link_raw}#{malicious_script}").html_safe?
9090
end
91-
91+
9292
def test_auto_link_should_sanitize_input_with_sanitize_options
9393
link_raw = %{http://www.rubyonrails.com?id=1&num=2}
9494
malicious_script = '<script>alert("malicious!")</script>'
9595
text_with_attributes = %{<a href="http://ruby-lang-org" target="_blank" data-malicious="inject">Ruby</a>}
96-
96+
9797
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>}
9898
assert_equal text_result, auto_link("#{link_raw}#{malicious_script}#{text_with_attributes}",
9999
:sanitize_options => {:attributes => ["target", "href"]},
100100
:html => {:class => 'big'})
101-
101+
102102
assert auto_link("#{link_raw}#{malicious_script}#{text_with_attributes}",
103103
:sanitize_options => {:attributes => ["target", "href"]},
104104
:html => {:class => 'big'}).html_safe?
@@ -107,7 +107,7 @@ def test_auto_link_should_sanitize_input_with_sanitize_options
107107
def test_auto_link_should_not_sanitize_input_when_sanitize_option_is_false
108108
link_raw = %{http://www.rubyonrails.com?id=1&num=2}
109109
malicious_script = '<script>alert("malicious!")</script>'
110-
110+
111111
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)
112112
assert !auto_link("#{link_raw}#{malicious_script}", :sanitize => false).html_safe?
113113
end
@@ -116,14 +116,8 @@ def test_auto_link_other_protocols
116116
ftp_raw = 'ftp://example.com/file.txt'
117117
assert_equal %(Download #{generate_result(ftp_raw)}), auto_link("Download #{ftp_raw}")
118118

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'
123120
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)
127121
end
128122

129123
def test_auto_link_already_linked
@@ -156,14 +150,14 @@ def test_auto_link_should_be_html_safe
156150
email_raw = '[email protected]'
157151
link_raw = 'http://www.rubyonrails.org'
158152
malicious_script = '<script>alert("malicious!")</script>'
159-
153+
160154
assert auto_link(nil).html_safe?, 'should be html safe'
161155
assert auto_link('').html_safe?, 'should be html safe'
162156
assert auto_link("#{link_raw} #{link_raw} #{link_raw}").html_safe?, 'should be html safe'
163157
assert auto_link("hello #{email_raw}").html_safe?, 'should be html safe'
164158
assert auto_link("hello #{email_raw} #{malicious_script}").html_safe?, 'should be html safe'
165159
end
166-
160+
167161
def test_auto_link_should_not_be_html_safe_when_sanitize_option_false
168162
email_raw = '[email protected]'
169163
link_raw = 'http://www.rubyonrails.org'
@@ -204,11 +198,8 @@ def test_auto_link
204198
email2_raw = '[email protected]'
205199
email2_result = %{<a href="mailto:#{email2_raw}">#{email2_raw}</a>}
206200
assert_equal email2_result, auto_link(email2_raw)
207-
208-
email3_raw = '[email protected]'
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)
212203

213204
link2_raw = 'www.rubyonrails.com'
214205
link2_result = generate_result(link2_raw, "http://#{link2_raw}")

0 commit comments

Comments
 (0)