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 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
- config = Sanitize::Config::RELAXED.dup
20
- config[:attributes][:all].push("id", "class")
21
- config[:attributes]["a"].push("rel")
22
- config[:elements].push("div", "hr")
23
- config
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
@@ -1,3 +1,3 @@
1
1
  module Govspeak
2
- VERSION = "1.6.2"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -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: 1.6.2
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-06-23 00:00:00.000000000 Z
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.3
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.3
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: 3676938548072228722
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: 3676938548072228722
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