html_terminator 3.0.0 → 4.0.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/Gemfile.ci +10 -0
- data/html_terminator.gemspec +1 -1
- data/lib/html_terminator.rb +1 -1
- data/lib/html_terminator/version.rb +2 -2
- data/spec/html_terminator_spec.rb +21 -16
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7290d4a6c7f8e108d9df4b7e77e75b6069bc74f2
|
4
|
+
data.tar.gz: 4f0facdb558e55c8ff3edb0344b3758b62bcb38a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5688b605b7dfbf502da3393b394b7924ecb053458fc469cec30dfcfddac971271fe2e04a73a6fdb9199122caa3850b0e110dddb528f68f2e2d78e80449b6944f
|
7
|
+
data.tar.gz: d30608cee5cb486746e7428ce5a0801a5710bebe0601338b0049bfa69c110cdcd24b99af96ab0755ea4c3c17b31e6c30f157945f49d3ea2279523bbfc6ccf742
|
data/.travis.yml
CHANGED
data/Gemfile.ci
ADDED
data/html_terminator.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["steel@polleverywhere.com", "matt@polleverywhere.com"]
|
11
11
|
spec.description = %q{Terminate Active Records fields of html}
|
12
12
|
spec.summary = %q{Terminate Active Records fields of html}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/polleverywhere/html_terminator/"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
data/lib/html_terminator.rb
CHANGED
@@ -11,7 +11,7 @@ module HtmlTerminator
|
|
11
11
|
if val.is_a?(String)
|
12
12
|
# Sanitize produces escaped content.
|
13
13
|
# Unescape it to get the raw html
|
14
|
-
CGI.unescapeHTML(Sanitize.fragment(val, config).strip)
|
14
|
+
CGI.unescapeHTML(Sanitize.fragment(val, config).strip)
|
15
15
|
else
|
16
16
|
val
|
17
17
|
end
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module HtmlTerminator
|
2
|
-
VERSION = "
|
3
|
-
end
|
2
|
+
VERSION = "4.0.0"
|
3
|
+
end
|
@@ -5,60 +5,65 @@ describe HtmlTerminator do
|
|
5
5
|
user = OnlyFirstName.new
|
6
6
|
|
7
7
|
user.first_name = "Hello <img>"
|
8
|
-
user.first_name.
|
8
|
+
expect(user.first_name).to eql("Hello")
|
9
9
|
|
10
10
|
user.last_name = "Hello <img>"
|
11
|
-
user.last_name.
|
11
|
+
expect(user.last_name).to eql("Hello <img>")
|
12
12
|
|
13
13
|
user.age = 3
|
14
|
-
user.age.
|
14
|
+
expect(user.age).to eql(3)
|
15
15
|
end
|
16
16
|
|
17
17
|
it "doesn't escape ampersands" do
|
18
18
|
user = OnlyFirstName.new
|
19
19
|
|
20
20
|
user.first_name = "A & B & C"
|
21
|
-
user.first_name.
|
21
|
+
expect(user.first_name).to eql("A & B & C")
|
22
22
|
end
|
23
23
|
|
24
24
|
it "skips sanitize when only one bracket" do
|
25
25
|
user = OnlyFirstName.new
|
26
26
|
|
27
27
|
user.first_name = "1 < 2"
|
28
|
-
user.first_name.
|
28
|
+
expect(user.first_name).to eql("1 < 2")
|
29
29
|
|
30
30
|
user.first_name = "2 > 1"
|
31
|
-
user.first_name.
|
31
|
+
expect(user.first_name).to eql("2 > 1")
|
32
32
|
end
|
33
33
|
|
34
34
|
it "handles ampersands" do
|
35
35
|
user = OnlyFirstName.new
|
36
36
|
|
37
37
|
user.first_name = "Mr. & Mrs. Smith"
|
38
|
-
user.first_name.
|
38
|
+
expect(user.first_name).to eql("Mr. & Mrs. Smith")
|
39
39
|
end
|
40
40
|
|
41
41
|
it "doesn't blow up if value is not a string" do
|
42
42
|
user = OnlyFirstName.new
|
43
43
|
user.first_name = 1
|
44
|
-
user.first_name.
|
44
|
+
expect(user.first_name).to eql("1")
|
45
45
|
end
|
46
46
|
|
47
47
|
it "honors options that are passed in" do
|
48
48
|
user = FirstNameWithOptions.new
|
49
49
|
user.first_name = "Hello <flexbox></flexbox><hr><br><img>"
|
50
|
-
user.first_name.
|
50
|
+
expect(user.first_name).to eql("Hello <flexbox></flexbox>")
|
51
51
|
end
|
52
52
|
|
53
53
|
describe "#sanitize" do
|
54
54
|
it "strips out all html by default" do
|
55
55
|
val = HtmlTerminator.sanitize "<flexbox></flexbox><hr><br><img>"
|
56
|
-
val.
|
56
|
+
expect(val).to eql("")
|
57
57
|
end
|
58
58
|
|
59
|
-
it "
|
59
|
+
it "does not mark the output as html_safe" do
|
60
60
|
val = HtmlTerminator.sanitize "<flexbox></flexbox><hr><br><img>"
|
61
|
-
val.html_safe
|
61
|
+
expect(val.html_safe?).to eql(false)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "does not escape output that isn't stripped" do
|
65
|
+
val = HtmlTerminator.sanitize "<div>I said, \"Hello, John O'hare.\"</div>"
|
66
|
+
expect(val).to eql("I said, \"Hello, John O'hare.\"")
|
62
67
|
end
|
63
68
|
end
|
64
69
|
|
@@ -67,8 +72,8 @@ describe HtmlTerminator do
|
|
67
72
|
user.first_name = "Hello <br><strong>strong</strong><em>em</em>"
|
68
73
|
user.last_name = "Hello <br><strong>strong</strong><em>em</em>"
|
69
74
|
|
70
|
-
user.first_name.
|
71
|
-
user.last_name.
|
75
|
+
expect(user.first_name).to eql("Hello <strong>strong</strong>em")
|
76
|
+
expect(user.last_name).to eql("Hello strong<em>em</em>")
|
72
77
|
end
|
73
78
|
|
74
79
|
it "sanitizes on validation" do
|
@@ -77,7 +82,7 @@ describe HtmlTerminator do
|
|
77
82
|
user.last_name = "Hello <br><strong>strong</strong><em>em</em>"
|
78
83
|
user.valid?
|
79
84
|
|
80
|
-
user.read_attribute(:first_name).
|
81
|
-
user.read_attribute(:last_name).
|
85
|
+
expect(user.read_attribute(:first_name)).to eql("Hello <strong>strong</strong>em")
|
86
|
+
expect(user.read_attribute(:last_name)).to eql("Hello strong<em>em</em>")
|
82
87
|
end
|
83
88
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html_terminator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steel Fu
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-07-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- ".gitignore"
|
65
65
|
- ".travis.yml"
|
66
66
|
- Gemfile
|
67
|
+
- Gemfile.ci
|
67
68
|
- Guardfile
|
68
69
|
- LICENSE.txt
|
69
70
|
- README.md
|
@@ -75,7 +76,7 @@ files:
|
|
75
76
|
- spec/html_terminator_spec.rb
|
76
77
|
- spec/spec_helper.rb
|
77
78
|
- spec/support/active_record.rb
|
78
|
-
homepage:
|
79
|
+
homepage: https://github.com/polleverywhere/html_terminator/
|
79
80
|
licenses:
|
80
81
|
- MIT
|
81
82
|
metadata: {}
|
@@ -95,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
96
|
version: '0'
|
96
97
|
requirements: []
|
97
98
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.5.1
|
99
100
|
signing_key:
|
100
101
|
specification_version: 4
|
101
102
|
summary: Terminate Active Records fields of html
|