govspeak 1.6.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +8 -0
- data/lib/govspeak/html_sanitizer.rb +11 -6
- data/lib/govspeak/version.rb +1 -1
- data/lib/with_deep_merge.rb +11 -0
- data/test/with_deep_merge_test.rb +18 -0
- metadata +9 -6
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 2.0.0
|
2
|
+
|
3
|
+
* Upgrade sanitize dependency to 2.1.0
|
4
|
+
* Now allows `address`, `bdi`, `hr` and `summary` elements by default.
|
5
|
+
* Allows colons in IDs
|
6
|
+
* BREAKING CHANGE: This changes the validation rules of HtmlSanitizer.
|
7
|
+
* Stop duplicate entries in the sanitization config
|
8
|
+
|
1
9
|
## 1.6.2
|
2
10
|
|
3
11
|
* Fix a bug with parsing of `$LegislativeList` and `$PriorityList` with `\r\n`
|
@@ -1,6 +1,9 @@
|
|
1
1
|
require 'sanitize'
|
2
|
+
require 'with_deep_merge'
|
2
3
|
|
3
4
|
class Govspeak::HtmlSanitizer
|
5
|
+
include WithDeepMerge
|
6
|
+
|
4
7
|
def initialize(dirty_html)
|
5
8
|
@dirty_html = dirty_html
|
6
9
|
end
|
@@ -16,10 +19,12 @@ class Govspeak::HtmlSanitizer
|
|
16
19
|
end
|
17
20
|
|
18
21
|
def sanitize_config
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
deep_merge(Sanitize::Config::RELAXED, {
|
23
|
+
attributes: {
|
24
|
+
:all => Sanitize::Config::RELAXED[:attributes][:all] + [ "id", "class" ],
|
25
|
+
"a" => Sanitize::Config::RELAXED[:attributes]["a"] + [ "rel" ],
|
26
|
+
},
|
27
|
+
elements: Sanitize::Config::RELAXED[:elements] + [ "div" ],
|
28
|
+
})
|
24
29
|
end
|
25
|
-
end
|
30
|
+
end
|
data/lib/govspeak/version.rb
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
module WithDeepMerge
|
2
|
+
def deep_merge(base_object, other_object)
|
3
|
+
if base_object.is_a?(Hash) && other_object.is_a?(Hash)
|
4
|
+
base_object.merge(other_object) { |_, base_value, other_value|
|
5
|
+
deep_merge(base_value, other_value)
|
6
|
+
}
|
7
|
+
else
|
8
|
+
other_object
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'with_deep_merge'
|
2
|
+
|
3
|
+
class WithDeepMergeTest < Test::Unit::TestCase
|
4
|
+
include WithDeepMerge
|
5
|
+
|
6
|
+
def test_simple_merge
|
7
|
+
base_hash = { "a" => "b" }
|
8
|
+
other_hash = { "c" => "d" }
|
9
|
+
assert_equal({ "a" => "b", "c" => "d" }, deep_merge(base_hash, other_hash))
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_recursive_merge
|
13
|
+
base_hash = { "a" => { "b" => "c", "d" => "e" } }
|
14
|
+
other_hash = { "a" => { "b" => "z", "f" => "g" } }
|
15
|
+
assert_equal({ "a" => { "b" => "z", "d" => "e", "f" => "g" } },
|
16
|
+
deep_merge(base_hash, other_hash))
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govspeak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-08-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: kramdown
|
@@ -51,7 +51,7 @@ dependencies:
|
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.0
|
54
|
+
version: 2.1.0
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -59,7 +59,7 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - ~>
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 2.0
|
62
|
+
version: 2.1.0
|
63
63
|
- !ruby/object:Gem::Dependency
|
64
64
|
name: nokogiri
|
65
65
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,6 +151,7 @@ extensions: []
|
|
151
151
|
extra_rdoc_files: []
|
152
152
|
files:
|
153
153
|
- lib/kramdown/parser/kramdown_with_automatic_external_links.rb
|
154
|
+
- lib/with_deep_merge.rb
|
154
155
|
- lib/govspeak.rb
|
155
156
|
- lib/govspeak/html_validator.rb
|
156
157
|
- lib/govspeak/kramdown_overrides.rb
|
@@ -163,6 +164,7 @@ files:
|
|
163
164
|
- Gemfile
|
164
165
|
- Rakefile
|
165
166
|
- test/govspeak_test_helper.rb
|
167
|
+
- test/with_deep_merge_test.rb
|
166
168
|
- test/html_validator_test.rb
|
167
169
|
- test/govspeak_test.rb
|
168
170
|
- test/html_sanitizer_test.rb
|
@@ -182,7 +184,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
182
184
|
version: '0'
|
183
185
|
segments:
|
184
186
|
- 0
|
185
|
-
hash:
|
187
|
+
hash: 3723599467826747284
|
186
188
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
189
|
none: false
|
188
190
|
requirements:
|
@@ -191,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
193
|
version: '0'
|
192
194
|
segments:
|
193
195
|
- 0
|
194
|
-
hash:
|
196
|
+
hash: 3723599467826747284
|
195
197
|
requirements: []
|
196
198
|
rubyforge_project:
|
197
199
|
rubygems_version: 1.8.23
|
@@ -200,6 +202,7 @@ specification_version: 3
|
|
200
202
|
summary: Markup language for single domain
|
201
203
|
test_files:
|
202
204
|
- test/govspeak_test_helper.rb
|
205
|
+
- test/with_deep_merge_test.rb
|
203
206
|
- test/html_validator_test.rb
|
204
207
|
- test/govspeak_test.rb
|
205
208
|
- test/html_sanitizer_test.rb
|