html_terminator 3.0.0 → 6.0.1
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 +5 -5
- data/.github/workflows/ci.yml +22 -0
- data/Gemfile +3 -4
- data/html_terminator.gemspec +3 -3
- data/lib/html_terminator/version.rb +2 -2
- data/lib/html_terminator.rb +3 -1
- data/spec/html_terminator_spec.rb +21 -16
- metadata +9 -11
- data/.travis.yml +0 -4
- data/Guardfile +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9a7a8946175692f847d9c8b647ff9eb519813406b5a5994a00c979404e20c777
|
4
|
+
data.tar.gz: ca19d579c5f12681c65d07663a538016651c4927b70365c29fabd0a05a13e7ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acc02f9bc1eb2811f1247f85b2c01b89f56374dd5fa8bcb7db22c10cdc2261a75d90c747c8c04db71ba535997b3b0dce5ddb8388baf136cc14f8c38fb6930b1a
|
7
|
+
data.tar.gz: d7c4a6e1e5ccce26db2b603325290ab324133896a9ca6d0566d8ed8ea42f72b55fab34d2d0c8a8eaf5ded653a1163e08b70b87f13aae39849d6378c35ec4ef19
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: CI
|
2
|
+
on: [push]
|
3
|
+
jobs:
|
4
|
+
lint-test:
|
5
|
+
name: Test
|
6
|
+
runs-on: ubuntu-latest
|
7
|
+
timeout-minutes: 10
|
8
|
+
strategy:
|
9
|
+
matrix:
|
10
|
+
ruby:
|
11
|
+
- 2.5
|
12
|
+
- 2.6
|
13
|
+
- 2.7
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
- uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: ${{ matrix.ruby }}
|
19
|
+
|
20
|
+
|
21
|
+
- run: bundle install
|
22
|
+
- run: bundle exec rspec
|
data/Gemfile
CHANGED
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($/)
|
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_development_dependency "bundler", "~>
|
21
|
+
spec.add_development_dependency "bundler", "~> 2.2.0"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
|
24
|
-
spec.add_runtime_dependency "sanitize", "~>
|
24
|
+
spec.add_runtime_dependency "sanitize", "~> 6.0.0"
|
25
25
|
end
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module HtmlTerminator
|
2
|
-
VERSION =
|
3
|
-
end
|
2
|
+
VERSION = '6.0.1'
|
3
|
+
end
|
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
|
@@ -58,6 +58,8 @@ module HtmlTerminator
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
61
|
+
rescue ActiveRecord::ConnectionNotEstablished
|
62
|
+
# Treat as if the table doesn't exist
|
61
63
|
end
|
62
64
|
end
|
63
65
|
|
@@ -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: 6.0.1
|
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:
|
12
|
+
date: 2021-11-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 2.2.0
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 2.2.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,14 +45,14 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: 6.0.0
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: 6.0.0
|
56
56
|
description: Terminate Active Records fields of html
|
57
57
|
email:
|
58
58
|
- steel@polleverywhere.com
|
@@ -61,10 +61,9 @@ executables: []
|
|
61
61
|
extensions: []
|
62
62
|
extra_rdoc_files: []
|
63
63
|
files:
|
64
|
+
- ".github/workflows/ci.yml"
|
64
65
|
- ".gitignore"
|
65
|
-
- ".travis.yml"
|
66
66
|
- Gemfile
|
67
|
-
- Guardfile
|
68
67
|
- LICENSE.txt
|
69
68
|
- README.md
|
70
69
|
- Rakefile
|
@@ -75,7 +74,7 @@ files:
|
|
75
74
|
- spec/html_terminator_spec.rb
|
76
75
|
- spec/spec_helper.rb
|
77
76
|
- spec/support/active_record.rb
|
78
|
-
homepage:
|
77
|
+
homepage: https://github.com/polleverywhere/html_terminator/
|
79
78
|
licenses:
|
80
79
|
- MIT
|
81
80
|
metadata: {}
|
@@ -94,8 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
93
|
- !ruby/object:Gem::Version
|
95
94
|
version: '0'
|
96
95
|
requirements: []
|
97
|
-
|
98
|
-
rubygems_version: 2.2.3
|
96
|
+
rubygems_version: 3.0.3.1
|
99
97
|
signing_key:
|
100
98
|
specification_version: 4
|
101
99
|
summary: Terminate Active Records fields of html
|
data/.travis.yml
DELETED