snail 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/snail.rb +4 -1
  2. data/test/snail_test.rb +3 -1
  3. metadata +4 -4
data/lib/snail.rb CHANGED
@@ -2,6 +2,9 @@ require 'snail/configurable'
2
2
  require 'snail/constants'
3
3
  require 'snail_helpers'
4
4
 
5
+ require 'cgi'
6
+ require 'active_support/core_ext/string/output_safety'
7
+
5
8
  class Snail
6
9
  include Configurable
7
10
 
@@ -44,7 +47,7 @@ class Snail
44
47
  end
45
48
 
46
49
  def to_html
47
- "<address>#{to_s.gsub("\n", '<br />')}</address>"
50
+ "<address>#{CGI.escapeHTML(to_s).gsub("\n", '<br />')}</address>".html_safe
48
51
  end
49
52
 
50
53
  # this method will get much larger. completeness is out of my scope at this time.
data/test/snail_test.rb CHANGED
@@ -92,7 +92,9 @@ class SnailTest < ActiveSupport::TestCase
92
92
 
93
93
  test "to_html" do
94
94
  s = Snail.new(@ca)
95
- assert_equal "<address>John Doe<br />12345 5th St<br />Somewheres NY 12345<br />CANADA</address>", s.to_html
95
+ s.name = 'John & Jane Doe'
96
+ assert_equal "<address>John &amp; Jane Doe<br />12345 5th St<br />Somewheres NY 12345<br />CANADA</address>", s.to_html
97
+ assert s.to_html.html_safe?
96
98
  end
97
99
  end
98
100
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snail
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 4
10
- version: 0.5.4
9
+ - 5
10
+ version: 0.5.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lance Ivy
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-06 00:00:00 -07:00
18
+ date: 2011-06-14 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies: []
21
21