govspeak 6.5.1 → 6.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +6 -5
- data/Rakefile +6 -3
- data/lib/govspeak.rb +56 -54
- data/lib/govspeak/html_sanitizer.rb +7 -4
- data/lib/govspeak/kramdown_overrides.rb +2 -2
- data/lib/govspeak/link_extractor.rb +3 -3
- data/lib/govspeak/post_processor.rb +25 -5
- data/lib/govspeak/presenters/attachment_presenter.rb +26 -26
- data/lib/govspeak/presenters/image_presenter.rb +2 -2
- data/lib/govspeak/structured_header_extractor.rb +2 -2
- data/lib/govspeak/version.rb +1 -1
- data/lib/kramdown/parser/govuk.rb +5 -6
- data/test/blockquote_extra_quote_remover_test.rb +25 -27
- data/test/govspeak_attachment_link_test.rb +0 -2
- data/test/govspeak_attachment_test.rb +0 -2
- data/test/govspeak_attachments_image_test.rb +2 -4
- data/test/govspeak_attachments_inline_test.rb +4 -6
- data/test/govspeak_button_test.rb +25 -27
- data/test/govspeak_contacts_test.rb +11 -13
- data/test/govspeak_extract_contact_content_ids_test.rb +0 -2
- data/test/govspeak_images_bang_test.rb +30 -32
- data/test/govspeak_images_test.rb +36 -38
- data/test/govspeak_link_extractor_test.rb +1 -1
- data/test/govspeak_link_test.rb +0 -2
- data/test/govspeak_structured_headers_test.rb +5 -4
- data/test/govspeak_table_with_headers_test.rb +67 -20
- data/test/govspeak_test.rb +80 -83
- data/test/govspeak_test_helper.rb +1 -1
- data/test/html_sanitizer_test.rb +9 -1
- data/test/presenters/h_card_presenter_test.rb +0 -2
- data/test/test_helper.rb +6 -2
- metadata +41 -35
@@ -49,7 +49,7 @@ module GovspeakTestHelper
|
|
49
49
|
lines = text.split "\n"
|
50
50
|
digits = Math.log10(lines.size + 2).ceil
|
51
51
|
lines.map
|
52
|
-
.with_index { |line, i| "%<number>#{digits}d: %<line>s"
|
52
|
+
.with_index { |line, i| sprintf("%<number>#{digits}d: %<line>s", number: i + 1, line: line) }
|
53
53
|
.join("\n")
|
54
54
|
end
|
55
55
|
end
|
data/test/html_sanitizer_test.rb
CHANGED
@@ -44,6 +44,15 @@ class HtmlSanitizerTest < Minitest::Test
|
|
44
44
|
)
|
45
45
|
end
|
46
46
|
|
47
|
+
test "allow data attributes on divs" do
|
48
|
+
html = "<div data-module='toggle' data-ecommerce-path='/' data-track-category='someDiv'>Test Div</div>"
|
49
|
+
|
50
|
+
assert_equal(
|
51
|
+
"<div data-module=\"toggle\" data-ecommerce-path=\"/\" data-track-category=\"someDiv\">Test Div</div>",
|
52
|
+
Govspeak::HtmlSanitizer.new(html).sanitize,
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
47
56
|
test "allows images on whitelisted domains" do
|
48
57
|
html = "<img src='http://allowed.com/image.jgp'>"
|
49
58
|
sanitized_html = Govspeak::HtmlSanitizer.new(html, allowed_image_hosts: ["allowed.com"]).sanitize
|
@@ -70,7 +79,6 @@ class HtmlSanitizerTest < Minitest::Test
|
|
70
79
|
assert_equal "<table><tbody><tr><th>thing</th><td>thing</td></tr></tbody></table>", Govspeak::HtmlSanitizer.new(html).sanitize
|
71
80
|
end
|
72
81
|
|
73
|
-
|
74
82
|
test "allows valid text-align properties on the style attribute for table cells and table headings" do
|
75
83
|
%w[left right center].each do |alignment|
|
76
84
|
html = "<table><thead><tr><th style=\"text-align: #{alignment}\">thing</th></tr></thead><tbody><tr><td style=\"text-align: #{alignment}\">thing</td></tr></tbody></table>"
|
data/test/test_helper.rb
CHANGED
@@ -4,7 +4,7 @@ require "simplecov-rcov"
|
|
4
4
|
SimpleCov.start
|
5
5
|
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
|
6
6
|
|
7
|
-
|
7
|
+
$LOAD_PATH.unshift(File.expand_path("../lib")) unless $LOAD_PATH.include?(File.expand_path("../lib"))
|
8
8
|
|
9
9
|
require "bundler"
|
10
10
|
Bundler.setup :default, :development, :test
|
@@ -16,7 +16,11 @@ class Minitest::Test
|
|
16
16
|
def test(name, &block)
|
17
17
|
clean_name = name.gsub(/\s+/, "_")
|
18
18
|
method = "test_#{clean_name.gsub(/\s+/, '_')}".to_sym
|
19
|
-
already_defined =
|
19
|
+
already_defined = begin
|
20
|
+
instance_method(method)
|
21
|
+
rescue StandardError
|
22
|
+
false
|
23
|
+
end
|
20
24
|
raise "#{method} exists" if already_defined
|
21
25
|
|
22
26
|
define_method(method, &block)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: govspeak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.5.
|
4
|
+
version: 6.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -54,16 +54,16 @@ dependencies:
|
|
54
54
|
name: govuk_publishing_components
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
|
-
- - "
|
57
|
+
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: '
|
59
|
+
version: '21.4'
|
60
60
|
type: :runtime
|
61
61
|
prerelease: false
|
62
62
|
version_requirements: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
|
-
- - "
|
64
|
+
- - "~>"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: '
|
66
|
+
version: '21.4'
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: htmlentities
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -96,16 +96,16 @@ dependencies:
|
|
96
96
|
name: kramdown
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
|
-
- - "
|
99
|
+
- - ">="
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
101
|
+
version: 2.3.0
|
102
102
|
type: :runtime
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
requirements:
|
106
|
-
- - "
|
106
|
+
- - ">="
|
107
107
|
- !ruby/object:Gem::Version
|
108
|
-
version:
|
108
|
+
version: 2.3.0
|
109
109
|
- !ruby/object:Gem::Dependency
|
110
110
|
name: nokogiri
|
111
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,30 +152,36 @@ dependencies:
|
|
152
152
|
name: sanitize
|
153
153
|
requirement: !ruby/object:Gem::Requirement
|
154
154
|
requirements:
|
155
|
-
- - "
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 5.2.1
|
158
|
+
- - "<"
|
156
159
|
- !ruby/object:Gem::Version
|
157
|
-
version: '
|
160
|
+
version: '6'
|
158
161
|
type: :runtime
|
159
162
|
prerelease: false
|
160
163
|
version_requirements: !ruby/object:Gem::Requirement
|
161
164
|
requirements:
|
162
|
-
- - "
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: 5.2.1
|
168
|
+
- - "<"
|
163
169
|
- !ruby/object:Gem::Version
|
164
|
-
version: '
|
170
|
+
version: '6'
|
165
171
|
- !ruby/object:Gem::Dependency
|
166
172
|
name: minitest
|
167
173
|
requirement: !ruby/object:Gem::Requirement
|
168
174
|
requirements:
|
169
175
|
- - "~>"
|
170
176
|
- !ruby/object:Gem::Version
|
171
|
-
version: 5.
|
177
|
+
version: 5.14.1
|
172
178
|
type: :development
|
173
179
|
prerelease: false
|
174
180
|
version_requirements: !ruby/object:Gem::Requirement
|
175
181
|
requirements:
|
176
182
|
- - "~>"
|
177
183
|
- !ruby/object:Gem::Version
|
178
|
-
version: 5.
|
184
|
+
version: 5.14.1
|
179
185
|
- !ruby/object:Gem::Dependency
|
180
186
|
name: pry-byebug
|
181
187
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,30 +200,30 @@ dependencies:
|
|
194
200
|
name: rake
|
195
201
|
requirement: !ruby/object:Gem::Requirement
|
196
202
|
requirements:
|
197
|
-
- - "
|
203
|
+
- - ">="
|
198
204
|
- !ruby/object:Gem::Version
|
199
|
-
version: 0
|
205
|
+
version: '0'
|
200
206
|
type: :development
|
201
207
|
prerelease: false
|
202
208
|
version_requirements: !ruby/object:Gem::Requirement
|
203
209
|
requirements:
|
204
|
-
- - "
|
210
|
+
- - ">="
|
205
211
|
- !ruby/object:Gem::Version
|
206
|
-
version: 0
|
212
|
+
version: '0'
|
207
213
|
- !ruby/object:Gem::Dependency
|
208
214
|
name: rubocop-govuk
|
209
215
|
requirement: !ruby/object:Gem::Requirement
|
210
216
|
requirements:
|
211
217
|
- - "~>"
|
212
218
|
- !ruby/object:Gem::Version
|
213
|
-
version:
|
219
|
+
version: 3.3.2
|
214
220
|
type: :development
|
215
221
|
prerelease: false
|
216
222
|
version_requirements: !ruby/object:Gem::Requirement
|
217
223
|
requirements:
|
218
224
|
- - "~>"
|
219
225
|
- !ruby/object:Gem::Version
|
220
|
-
version:
|
226
|
+
version: 3.3.2
|
221
227
|
- !ruby/object:Gem::Dependency
|
222
228
|
name: simplecov
|
223
229
|
requirement: !ruby/object:Gem::Requirement
|
@@ -365,23 +371,23 @@ signing_key:
|
|
365
371
|
specification_version: 4
|
366
372
|
summary: Markup language for single domain
|
367
373
|
test_files:
|
368
|
-
- test/
|
369
|
-
- test/
|
370
|
-
- test/
|
371
|
-
- test/
|
374
|
+
- test/govspeak_link_extractor_test.rb
|
375
|
+
- test/govspeak_structured_headers_test.rb
|
376
|
+
- test/govspeak_images_bang_test.rb
|
377
|
+
- test/govspeak_button_test.rb
|
372
378
|
- test/govspeak_table_with_headers_test.rb
|
379
|
+
- test/govspeak_extract_contact_content_ids_test.rb
|
380
|
+
- test/blockquote_extra_quote_remover_test.rb
|
381
|
+
- test/govspeak_test_helper.rb
|
373
382
|
- test/govspeak_link_test.rb
|
374
|
-
- test/
|
375
|
-
- test/
|
383
|
+
- test/govspeak_images_test.rb
|
384
|
+
- test/govspeak_attachment_link_test.rb
|
376
385
|
- test/govspeak_contacts_test.rb
|
377
386
|
- test/test_helper.rb
|
387
|
+
- test/html_validator_test.rb
|
388
|
+
- test/html_sanitizer_test.rb
|
389
|
+
- test/govspeak_attachments_inline_test.rb
|
378
390
|
- test/govspeak_test.rb
|
391
|
+
- test/govspeak_attachment_test.rb
|
379
392
|
- test/govspeak_attachments_image_test.rb
|
380
|
-
- test/html_validator_test.rb
|
381
|
-
- test/govspeak_structured_headers_test.rb
|
382
|
-
- test/govspeak_extract_contact_content_ids_test.rb
|
383
|
-
- test/blockquote_extra_quote_remover_test.rb
|
384
393
|
- test/presenters/h_card_presenter_test.rb
|
385
|
-
- test/govspeak_button_test.rb
|
386
|
-
- test/govspeak_test_helper.rb
|
387
|
-
- test/html_sanitizer_test.rb
|