govspeak 6.4.0 → 6.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbff4078955867159e914ac1dd26310ab9295a0618a58529b42b64c7e55399fd
4
- data.tar.gz: ce83e999fab5cec2919c21b4561cf06a26c42056dde7c1740b04ca7b1df9d1df
3
+ metadata.gz: 691092344fa56f8643bda4f29f8f0a18344515254b042fb15771375489395015
4
+ data.tar.gz: 529021924ad18fccfabda572204e59b33867578e548816ab093e2d51b30e059f
5
5
  SHA512:
6
- metadata.gz: 1972d6f7430d74f570dd23e9e529e581460fb02b535c834abada9c1c14b4d59914ddfeedec8c6209e6992a303c44211c0759fd9592ab5e9be42b776824d5efcb
7
- data.tar.gz: 139c744c3c51456f6ceac2b75f1cba186cdca54cf518b06b36768bd675560e00f9c95306228b076adadd6f08c6c2ad505447df42e5cce52095fc874bc4eeff21
6
+ metadata.gz: a870b551730a2a07f5a85bdb06df18b56018f3a700d21469d8c1804fe51d044ae7beb5455a8d1e332f44e003ed2d6231eb9f36fd72b0578de19cc408973074f0
7
+ data.tar.gz: d0b4ca4cf824216c139094d33fdd1a9ddf98800db9aa94b077b454cfce35e98713b1b6e850c63817242f5cc3e381aaa9633062d1b01c3a7450ec6a64876632ee
@@ -1,3 +1,7 @@
1
+ ## 6.5.0
2
+
3
+ * Allow data attributes on links
4
+
1
5
  ## 6.4.0
2
6
 
3
7
  * Add table heading syntax that allows a table cell outside of `thead` to be marked as a table heading with a scope of row. (PR#161)
@@ -48,21 +48,13 @@ class Govspeak::HtmlSanitizer
48
48
  Sanitize.clean(@dirty_html, Sanitize::Config.merge(sanitize_config, transformers: transformers))
49
49
  end
50
50
 
51
- def button_sanitize_config
52
- %w[
53
- data-module
54
- data-tracking-code
55
- data-tracking-name
56
- ]
57
- end
58
-
59
51
  def sanitize_config
60
52
  Sanitize::Config.merge(
61
53
  Sanitize::Config::RELAXED,
62
54
  elements: Sanitize::Config::RELAXED[:elements] + %w[govspeak-embed-attachment govspeak-embed-attachment-link],
63
55
  attributes: {
64
56
  :all => Sanitize::Config::RELAXED[:attributes][:all] + %w[role aria-label],
65
- "a" => Sanitize::Config::RELAXED[:attributes]["a"] + button_sanitize_config,
57
+ "a" => Sanitize::Config::RELAXED[:attributes]["a"] + [:data],
66
58
  "th" => Sanitize::Config::RELAXED[:attributes]["th"] + %w[style],
67
59
  "td" => Sanitize::Config::RELAXED[:attributes]["td"] + %w[style],
68
60
  "govspeak-embed-attachment" => %w[content-id],
@@ -1,3 +1,3 @@
1
1
  module Govspeak
2
- VERSION = "6.4.0".freeze
2
+ VERSION = "6.5.0".freeze
3
3
  end
@@ -35,6 +35,15 @@ class HtmlSanitizerTest < Minitest::Test
35
35
  )
36
36
  end
37
37
 
38
+ test "allow data attributes on links" do
39
+ html = "<a href='/' data-module='track-click' data-ecommerce-path='/' data-track-category='linkClicked'>Test Link</a>"
40
+
41
+ assert_equal(
42
+ "<a href=\"/\" data-module=\"track-click\" data-ecommerce-path=\"/\" data-track-category=\"linkClicked\">Test Link</a>",
43
+ Govspeak::HtmlSanitizer.new(html).sanitize
44
+ )
45
+ end
46
+
38
47
  test "allows images on whitelisted domains" do
39
48
  html = "<img src='http://allowed.com/image.jgp'>"
40
49
  sanitized_html = Govspeak::HtmlSanitizer.new(html, allowed_image_hosts: ['allowed.com']).sanitize
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.4.0
4
+ version: 6.5.0
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: 2019-07-22 00:00:00.000000000 Z
11
+ date: 2019-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -359,23 +359,23 @@ signing_key:
359
359
  specification_version: 4
360
360
  summary: Markup language for single domain
361
361
  test_files:
362
- - test/govspeak_attachments_inline_test.rb
363
- - test/govspeak_attachment_test.rb
364
362
  - test/govspeak_attachment_link_test.rb
365
- - test/govspeak_images_test.rb
366
- - test/govspeak_table_with_headers_test.rb
367
- - test/govspeak_link_test.rb
368
- - test/govspeak_images_bang_test.rb
369
- - test/govspeak_link_extractor_test.rb
370
- - test/govspeak_contacts_test.rb
371
363
  - test/test_helper.rb
364
+ - test/govspeak_button_test.rb
372
365
  - test/govspeak_test.rb
373
- - test/govspeak_attachments_image_test.rb
374
366
  - test/html_validator_test.rb
375
- - test/govspeak_structured_headers_test.rb
376
- - test/govspeak_extract_contact_content_ids_test.rb
377
- - test/blockquote_extra_quote_remover_test.rb
378
- - test/presenters/h_card_presenter_test.rb
379
- - test/govspeak_button_test.rb
367
+ - test/govspeak_attachment_test.rb
368
+ - test/govspeak_contacts_test.rb
380
369
  - test/govspeak_test_helper.rb
370
+ - test/blockquote_extra_quote_remover_test.rb
371
+ - test/govspeak_table_with_headers_test.rb
372
+ - test/govspeak_attachments_image_test.rb
381
373
  - test/html_sanitizer_test.rb
374
+ - test/govspeak_link_test.rb
375
+ - test/govspeak_extract_contact_content_ids_test.rb
376
+ - test/govspeak_structured_headers_test.rb
377
+ - test/govspeak_images_test.rb
378
+ - test/presenters/h_card_presenter_test.rb
379
+ - test/govspeak_images_bang_test.rb
380
+ - test/govspeak_link_extractor_test.rb
381
+ - test/govspeak_attachments_inline_test.rb