slimmer 15.5.1 → 15.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/slimmer.rb +1 -0
- data/lib/slimmer/processors/feedback_url_swapper.rb +34 -0
- data/lib/slimmer/skin.rb +1 -0
- data/lib/slimmer/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f9dab4037bbee9ec372a2d3093b8645d973ef8db63c8accd2d83bfb6a0f0e46
|
4
|
+
data.tar.gz: e8551a6f783608f5216ef2caa3ab23b7f15c6e8dca7ef27d1e7cad5b0f58fa2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5644a0a8217c1774a288573c9c6953db43c9f8a7b9f6d629a5515a79b953f05f4013cd9e7d55405f6df7e536213569d3e400ec5ae751e5b4a46828a4c93e81f4
|
7
|
+
data.tar.gz: b5e5d006ad1c69f687efc1201a13b3da4dd5efcbe6620cebf181a4fee49d4bebfc18beb15f2e9b370835c955baa58fa9b79d992d8c4e89484cab2e49c8734733
|
data/CHANGELOG.md
CHANGED
data/lib/slimmer.rb
CHANGED
@@ -32,6 +32,7 @@ module Slimmer
|
|
32
32
|
autoload :BodyClassCopier, "slimmer/processors/body_class_copier"
|
33
33
|
autoload :BodyInserter, "slimmer/processors/body_inserter"
|
34
34
|
autoload :ConditionalCommentMover, "slimmer/processors/conditional_comment_mover"
|
35
|
+
autoload :FeedbackURLSwapper, "slimmer/processors/feedback_url_swapper"
|
35
36
|
autoload :MetadataInserter, "slimmer/processors/metadata_inserter"
|
36
37
|
autoload :HeaderContextInserter, "slimmer/processors/header_context_inserter"
|
37
38
|
autoload :InsideHeaderInserter, "slimmer/processors/inside_header_inserter"
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Slimmer::Processors
|
2
|
+
class FeedbackURLSwapper
|
3
|
+
def initialize(request, headers)
|
4
|
+
@headers = headers
|
5
|
+
@request = request
|
6
|
+
end
|
7
|
+
|
8
|
+
def filter(_src, dest)
|
9
|
+
return dest unless is_gem_layout?
|
10
|
+
|
11
|
+
original_url_without_pii = remove_pii(@request.base_url + @request.fullpath)
|
12
|
+
dest.at_css(".gem-c-feedback input[name='url']").set_attribute("value", original_url_without_pii)
|
13
|
+
|
14
|
+
full_path_without_pii = remove_pii(@request.fullpath)
|
15
|
+
dest.at_css(".gem-c-feedback input[name='email_survey_signup[survey_source]']").set_attribute("value", full_path_without_pii)
|
16
|
+
|
17
|
+
dest
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# This PII removal is also found in the [feedback component in the GOV.UK
|
23
|
+
# Publishing Components gem](https://git.io/JcCIE), and any changes made
|
24
|
+
# need to be kept in sync.
|
25
|
+
def remove_pii(string)
|
26
|
+
email_regex = /[^\s=\/?&]+(?:@|%40)[^\s=\/?&]+/
|
27
|
+
string.dup.force_encoding("UTF-8").gsub(email_regex, "[email]")
|
28
|
+
end
|
29
|
+
|
30
|
+
def is_gem_layout?
|
31
|
+
@headers[Slimmer::Headers::TEMPLATE_HEADER]&.starts_with?("gem_layout")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/slimmer/skin.rb
CHANGED
@@ -109,6 +109,7 @@ module Slimmer
|
|
109
109
|
Processors::NavigationMover.new(self),
|
110
110
|
Processors::ConditionalCommentMover.new,
|
111
111
|
Processors::BodyInserter.new(wrapper_id, template_wrapper_id, response.headers),
|
112
|
+
Processors::FeedbackURLSwapper.new(source_request, response.headers),
|
112
113
|
Processors::BodyClassCopier.new,
|
113
114
|
Processors::InsideHeaderInserter.new,
|
114
115
|
Processors::HeaderContextInserter.new,
|
data/lib/slimmer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slimmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 15.
|
4
|
+
version: 15.6.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: 2021-
|
11
|
+
date: 2021-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -256,6 +256,7 @@ files:
|
|
256
256
|
- lib/slimmer/processors/body_class_copier.rb
|
257
257
|
- lib/slimmer/processors/body_inserter.rb
|
258
258
|
- lib/slimmer/processors/conditional_comment_mover.rb
|
259
|
+
- lib/slimmer/processors/feedback_url_swapper.rb
|
259
260
|
- lib/slimmer/processors/header_context_inserter.rb
|
260
261
|
- lib/slimmer/processors/inside_header_inserter.rb
|
261
262
|
- lib/slimmer/processors/metadata_inserter.rb
|