html_safe_flash 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7f9306fee0b449552fa6cc6dd75391a001a1a90d2aa98ac051bac4c3ebfa0d31
4
+ data.tar.gz: bf2a425302554f4b1da2c97f5a9250cc55fa12cb27e4cec09e9272a3a02c85e6
5
+ SHA512:
6
+ metadata.gz: 130c82ce8cb75498d6fb8e772ec675683eb73585d2e1d96c85c22eddd621a12b2adc7852a8e6cb66b26b8db189592943e88013e9c6fc5907fa1b4b21310f0ec1
7
+ data.tar.gz: fc066c9f401867f04ddc5ecd2b49286c4ee205ce3001cf080f998b154e1c70d6e377ef8a02e43fd83c781e5584c255e19ce02d16cfaf6c047e396330900a3ed8
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ require:
2
+ - standard
3
+ - rubocop-minitest
4
+
5
+ inherit_gem:
6
+ standard: config/base.yml
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.0
data/.standard.yml ADDED
@@ -0,0 +1,2 @@
1
+ ignore:
2
+ - test/unit/rails_flash_hash_test.rb
data/Appraisals ADDED
@@ -0,0 +1,11 @@
1
+ appraise "rails-main" do
2
+ gem "rails", github: "rails/rails"
3
+ end
4
+
5
+ appraise "rails-7" do
6
+ gem "rails", "~> 7.0"
7
+ end
8
+
9
+ appraise "rails-6.1" do
10
+ gem "rails", "~> 6.1"
11
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-01-08
4
+
5
+ - Initial release
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in html_safe_flash.gemspec
6
+ gemspec
7
+
8
+ gem "minitest", "~> 5.17"
9
+ gem "rake", "~> 13.0"
10
+ gem "rubocop-minitest", "~> 0.25"
11
+ gem "standard", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,200 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ html_safe_flash (0.1.0)
5
+ rails (>= 6)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (7.0.4)
11
+ actionpack (= 7.0.4)
12
+ activesupport (= 7.0.4)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (7.0.4)
16
+ actionpack (= 7.0.4)
17
+ activejob (= 7.0.4)
18
+ activerecord (= 7.0.4)
19
+ activestorage (= 7.0.4)
20
+ activesupport (= 7.0.4)
21
+ mail (>= 2.7.1)
22
+ net-imap
23
+ net-pop
24
+ net-smtp
25
+ actionmailer (7.0.4)
26
+ actionpack (= 7.0.4)
27
+ actionview (= 7.0.4)
28
+ activejob (= 7.0.4)
29
+ activesupport (= 7.0.4)
30
+ mail (~> 2.5, >= 2.5.4)
31
+ net-imap
32
+ net-pop
33
+ net-smtp
34
+ rails-dom-testing (~> 2.0)
35
+ actionpack (7.0.4)
36
+ actionview (= 7.0.4)
37
+ activesupport (= 7.0.4)
38
+ rack (~> 2.0, >= 2.2.0)
39
+ rack-test (>= 0.6.3)
40
+ rails-dom-testing (~> 2.0)
41
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
42
+ actiontext (7.0.4)
43
+ actionpack (= 7.0.4)
44
+ activerecord (= 7.0.4)
45
+ activestorage (= 7.0.4)
46
+ activesupport (= 7.0.4)
47
+ globalid (>= 0.6.0)
48
+ nokogiri (>= 1.8.5)
49
+ actionview (7.0.4)
50
+ activesupport (= 7.0.4)
51
+ builder (~> 3.1)
52
+ erubi (~> 1.4)
53
+ rails-dom-testing (~> 2.0)
54
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
55
+ activejob (7.0.4)
56
+ activesupport (= 7.0.4)
57
+ globalid (>= 0.3.6)
58
+ activemodel (7.0.4)
59
+ activesupport (= 7.0.4)
60
+ activerecord (7.0.4)
61
+ activemodel (= 7.0.4)
62
+ activesupport (= 7.0.4)
63
+ activestorage (7.0.4)
64
+ actionpack (= 7.0.4)
65
+ activejob (= 7.0.4)
66
+ activerecord (= 7.0.4)
67
+ activesupport (= 7.0.4)
68
+ marcel (~> 1.0)
69
+ mini_mime (>= 1.1.0)
70
+ activesupport (7.0.4)
71
+ concurrent-ruby (~> 1.0, >= 1.0.2)
72
+ i18n (>= 1.6, < 2)
73
+ minitest (>= 5.1)
74
+ tzinfo (~> 2.0)
75
+ appraisal (2.4.1)
76
+ bundler
77
+ rake
78
+ thor (>= 0.14.0)
79
+ ast (2.4.2)
80
+ builder (3.2.4)
81
+ concurrent-ruby (1.1.10)
82
+ crass (1.0.6)
83
+ date (3.3.3)
84
+ erubi (1.12.0)
85
+ globalid (1.0.0)
86
+ activesupport (>= 5.0)
87
+ i18n (1.12.0)
88
+ concurrent-ruby (~> 1.0)
89
+ json (2.6.3)
90
+ language_server-protocol (3.17.0.2)
91
+ loofah (2.19.1)
92
+ crass (~> 1.0.2)
93
+ nokogiri (>= 1.5.9)
94
+ mail (2.8.0)
95
+ mini_mime (>= 0.1.1)
96
+ net-imap
97
+ net-pop
98
+ net-smtp
99
+ marcel (1.0.2)
100
+ method_source (1.0.0)
101
+ mini_mime (1.1.2)
102
+ mini_portile2 (2.8.1)
103
+ minitest (5.17.0)
104
+ net-imap (0.3.4)
105
+ date
106
+ net-protocol
107
+ net-pop (0.1.2)
108
+ net-protocol
109
+ net-protocol (0.2.1)
110
+ timeout
111
+ net-smtp (0.3.3)
112
+ net-protocol
113
+ nio4r (2.5.8)
114
+ nokogiri (1.13.10)
115
+ mini_portile2 (~> 2.8.0)
116
+ racc (~> 1.4)
117
+ parallel (1.22.1)
118
+ parser (3.2.0.0)
119
+ ast (~> 2.4.1)
120
+ racc (1.6.2)
121
+ rack (2.2.5)
122
+ rack-test (2.0.2)
123
+ rack (>= 1.3)
124
+ rails (7.0.4)
125
+ actioncable (= 7.0.4)
126
+ actionmailbox (= 7.0.4)
127
+ actionmailer (= 7.0.4)
128
+ actionpack (= 7.0.4)
129
+ actiontext (= 7.0.4)
130
+ actionview (= 7.0.4)
131
+ activejob (= 7.0.4)
132
+ activemodel (= 7.0.4)
133
+ activerecord (= 7.0.4)
134
+ activestorage (= 7.0.4)
135
+ activesupport (= 7.0.4)
136
+ bundler (>= 1.15.0)
137
+ railties (= 7.0.4)
138
+ rails-dom-testing (2.0.3)
139
+ activesupport (>= 4.2.0)
140
+ nokogiri (>= 1.6)
141
+ rails-html-sanitizer (1.4.4)
142
+ loofah (~> 2.19, >= 2.19.1)
143
+ railties (7.0.4)
144
+ actionpack (= 7.0.4)
145
+ activesupport (= 7.0.4)
146
+ method_source
147
+ rake (>= 12.2)
148
+ thor (~> 1.0)
149
+ zeitwerk (~> 2.5)
150
+ rainbow (3.1.1)
151
+ rake (13.0.6)
152
+ regexp_parser (2.6.1)
153
+ rexml (3.2.5)
154
+ rubocop (1.42.0)
155
+ json (~> 2.3)
156
+ parallel (~> 1.10)
157
+ parser (>= 3.1.2.1)
158
+ rainbow (>= 2.2.2, < 4.0)
159
+ regexp_parser (>= 1.8, < 3.0)
160
+ rexml (>= 3.2.5, < 4.0)
161
+ rubocop-ast (>= 1.24.1, < 2.0)
162
+ ruby-progressbar (~> 1.7)
163
+ unicode-display_width (>= 1.4.0, < 3.0)
164
+ rubocop-ast (1.24.1)
165
+ parser (>= 3.1.1.0)
166
+ rubocop-minitest (0.25.1)
167
+ rubocop (>= 0.90, < 2.0)
168
+ rubocop-performance (1.15.2)
169
+ rubocop (>= 1.7.0, < 2.0)
170
+ rubocop-ast (>= 0.4.0)
171
+ ruby-progressbar (1.11.0)
172
+ standard (1.21.1)
173
+ language_server-protocol (~> 3.17.0.2)
174
+ rubocop (= 1.42.0)
175
+ rubocop-performance (= 1.15.2)
176
+ thor (1.2.1)
177
+ timeout (0.3.1)
178
+ tzinfo (2.0.5)
179
+ concurrent-ruby (~> 1.0)
180
+ unicode-display_width (2.4.2)
181
+ websocket-driver (0.7.5)
182
+ websocket-extensions (>= 0.1.0)
183
+ websocket-extensions (0.1.5)
184
+ zeitwerk (2.6.6)
185
+
186
+ PLATFORMS
187
+ ruby
188
+ x86_64-darwin-21
189
+ x86_64-linux
190
+
191
+ DEPENDENCIES
192
+ appraisal
193
+ html_safe_flash!
194
+ minitest (~> 5.17)
195
+ rake (~> 13.0)
196
+ rubocop-minitest (~> 0.25)
197
+ standard (~> 1.21)
198
+
199
+ BUNDLED WITH
200
+ 2.4.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Milo Winningham
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # html_safe_flash
2
+ Use `html_safe` strings naturally in Rails flash messages.
3
+
4
+ ## Usage
5
+ Just store any `html_safe` string in a flash message!
6
+
7
+ Since Rails 4.1+ (which switched to JSON as the default cookie serializer), code like this does not work as one might expect:
8
+
9
+ ```ruby
10
+ class PostsController < ApplicationController
11
+ def create
12
+ @post.save!
13
+ flash[:success] = "Done! Go view your #{link_to "post", @post}.".html_safe
14
+ redirect_to :index
15
+ end
16
+ end
17
+ ```
18
+
19
+ Calling `html_safe` on the string returns a `ActiveSupport::SafeBuffer` object.
20
+ When Rails serializes it to the session cookie, this object is stored as a normal string, losing its `html_safe?` status when loaded on the next page.
21
+
22
+ Some applications work around this issue by rendering every flash message with `html_safe` or `raw`.
23
+ This isn't always a problem, but can easily create a cross-site scripting security vulnerability if a message ever includes unescaped user input.
24
+
25
+ With this gem installed however, `flash[:success].html_safe?` will return true on the next request because html_safe metadata is tracked internally — `html_safe_flash` patches `ActionDispatch::Flash::FlashHash` to store something like this in the session:
26
+
27
+ ```json
28
+ {
29
+ "success": "Done! Go view your <a href='/posts/1'>post</a>.",
30
+ "_html_safe_keys": ["success"]
31
+ }
32
+ ```
33
+
34
+ On the next request, the message is automatically converted back to a `ActiveSupport::SafeBuffer` and the extra metadata is removed.
35
+
36
+ ## Installation
37
+ Add this line to your application's Gemfile after `rails`:
38
+
39
+ ```ruby
40
+ gem "html_safe_flash"
41
+ ```
42
+
43
+ ## License
44
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ require "standard/rake"
13
+
14
+ task default: %i[test standard]
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "minitest", "~> 5.17"
6
+ gem "rake", "~> 13.0"
7
+ gem "rubocop-minitest", "~> 0.25"
8
+ gem "standard", "~> 1.21"
9
+ gem "rails", "~> 6.1"
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,202 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ html_safe_flash (0.1.0)
5
+ rails (>= 6)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (6.1.7)
11
+ actionpack (= 6.1.7)
12
+ activesupport (= 6.1.7)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (6.1.7)
16
+ actionpack (= 6.1.7)
17
+ activejob (= 6.1.7)
18
+ activerecord (= 6.1.7)
19
+ activestorage (= 6.1.7)
20
+ activesupport (= 6.1.7)
21
+ mail (>= 2.7.1)
22
+ actionmailer (6.1.7)
23
+ actionpack (= 6.1.7)
24
+ actionview (= 6.1.7)
25
+ activejob (= 6.1.7)
26
+ activesupport (= 6.1.7)
27
+ mail (~> 2.5, >= 2.5.4)
28
+ rails-dom-testing (~> 2.0)
29
+ actionpack (6.1.7)
30
+ actionview (= 6.1.7)
31
+ activesupport (= 6.1.7)
32
+ rack (~> 2.0, >= 2.0.9)
33
+ rack-test (>= 0.6.3)
34
+ rails-dom-testing (~> 2.0)
35
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
+ actiontext (6.1.7)
37
+ actionpack (= 6.1.7)
38
+ activerecord (= 6.1.7)
39
+ activestorage (= 6.1.7)
40
+ activesupport (= 6.1.7)
41
+ nokogiri (>= 1.8.5)
42
+ actionview (6.1.7)
43
+ activesupport (= 6.1.7)
44
+ builder (~> 3.1)
45
+ erubi (~> 1.4)
46
+ rails-dom-testing (~> 2.0)
47
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
+ activejob (6.1.7)
49
+ activesupport (= 6.1.7)
50
+ globalid (>= 0.3.6)
51
+ activemodel (6.1.7)
52
+ activesupport (= 6.1.7)
53
+ activerecord (6.1.7)
54
+ activemodel (= 6.1.7)
55
+ activesupport (= 6.1.7)
56
+ activestorage (6.1.7)
57
+ actionpack (= 6.1.7)
58
+ activejob (= 6.1.7)
59
+ activerecord (= 6.1.7)
60
+ activesupport (= 6.1.7)
61
+ marcel (~> 1.0)
62
+ mini_mime (>= 1.1.0)
63
+ activesupport (6.1.7)
64
+ concurrent-ruby (~> 1.0, >= 1.0.2)
65
+ i18n (>= 1.6, < 2)
66
+ minitest (>= 5.1)
67
+ tzinfo (~> 2.0)
68
+ zeitwerk (~> 2.3)
69
+ appraisal (2.4.1)
70
+ bundler
71
+ rake
72
+ thor (>= 0.14.0)
73
+ ast (2.4.2)
74
+ builder (3.2.4)
75
+ concurrent-ruby (1.1.10)
76
+ crass (1.0.6)
77
+ date (3.3.3)
78
+ erubi (1.12.0)
79
+ globalid (1.0.0)
80
+ activesupport (>= 5.0)
81
+ i18n (1.12.0)
82
+ concurrent-ruby (~> 1.0)
83
+ json (2.6.3)
84
+ language_server-protocol (3.17.0.2)
85
+ loofah (2.19.1)
86
+ crass (~> 1.0.2)
87
+ nokogiri (>= 1.5.9)
88
+ mail (2.8.0)
89
+ mini_mime (>= 0.1.1)
90
+ net-imap
91
+ net-pop
92
+ net-smtp
93
+ marcel (1.0.2)
94
+ method_source (1.0.0)
95
+ mini_mime (1.1.2)
96
+ mini_portile2 (2.8.1)
97
+ minitest (5.17.0)
98
+ net-imap (0.3.4)
99
+ date
100
+ net-protocol
101
+ net-pop (0.1.2)
102
+ net-protocol
103
+ net-protocol (0.2.1)
104
+ timeout
105
+ net-smtp (0.3.3)
106
+ net-protocol
107
+ nio4r (2.5.8)
108
+ nokogiri (1.13.10)
109
+ mini_portile2 (~> 2.8.0)
110
+ racc (~> 1.4)
111
+ parallel (1.22.1)
112
+ parser (3.2.0.0)
113
+ ast (~> 2.4.1)
114
+ racc (1.6.2)
115
+ rack (2.2.5)
116
+ rack-test (2.0.2)
117
+ rack (>= 1.3)
118
+ rails (6.1.7)
119
+ actioncable (= 6.1.7)
120
+ actionmailbox (= 6.1.7)
121
+ actionmailer (= 6.1.7)
122
+ actionpack (= 6.1.7)
123
+ actiontext (= 6.1.7)
124
+ actionview (= 6.1.7)
125
+ activejob (= 6.1.7)
126
+ activemodel (= 6.1.7)
127
+ activerecord (= 6.1.7)
128
+ activestorage (= 6.1.7)
129
+ activesupport (= 6.1.7)
130
+ bundler (>= 1.15.0)
131
+ railties (= 6.1.7)
132
+ sprockets-rails (>= 2.0.0)
133
+ rails-dom-testing (2.0.3)
134
+ activesupport (>= 4.2.0)
135
+ nokogiri (>= 1.6)
136
+ rails-html-sanitizer (1.4.4)
137
+ loofah (~> 2.19, >= 2.19.1)
138
+ railties (6.1.7)
139
+ actionpack (= 6.1.7)
140
+ activesupport (= 6.1.7)
141
+ method_source
142
+ rake (>= 12.2)
143
+ thor (~> 1.0)
144
+ rainbow (3.1.1)
145
+ rake (13.0.6)
146
+ regexp_parser (2.6.1)
147
+ rexml (3.2.5)
148
+ rubocop (1.42.0)
149
+ json (~> 2.3)
150
+ parallel (~> 1.10)
151
+ parser (>= 3.1.2.1)
152
+ rainbow (>= 2.2.2, < 4.0)
153
+ regexp_parser (>= 1.8, < 3.0)
154
+ rexml (>= 3.2.5, < 4.0)
155
+ rubocop-ast (>= 1.24.1, < 2.0)
156
+ ruby-progressbar (~> 1.7)
157
+ unicode-display_width (>= 1.4.0, < 3.0)
158
+ rubocop-ast (1.24.1)
159
+ parser (>= 3.1.1.0)
160
+ rubocop-minitest (0.25.1)
161
+ rubocop (>= 0.90, < 2.0)
162
+ rubocop-performance (1.15.2)
163
+ rubocop (>= 1.7.0, < 2.0)
164
+ rubocop-ast (>= 0.4.0)
165
+ ruby-progressbar (1.11.0)
166
+ sprockets (4.2.0)
167
+ concurrent-ruby (~> 1.0)
168
+ rack (>= 2.2.4, < 4)
169
+ sprockets-rails (3.4.2)
170
+ actionpack (>= 5.2)
171
+ activesupport (>= 5.2)
172
+ sprockets (>= 3.0.0)
173
+ standard (1.21.1)
174
+ language_server-protocol (~> 3.17.0.2)
175
+ rubocop (= 1.42.0)
176
+ rubocop-performance (= 1.15.2)
177
+ thor (1.2.1)
178
+ timeout (0.3.1)
179
+ tzinfo (2.0.5)
180
+ concurrent-ruby (~> 1.0)
181
+ unicode-display_width (2.4.2)
182
+ websocket-driver (0.7.5)
183
+ websocket-extensions (>= 0.1.0)
184
+ websocket-extensions (0.1.5)
185
+ zeitwerk (2.6.6)
186
+
187
+ PLATFORMS
188
+ ruby
189
+ x86_64-darwin-21
190
+ x86_64-linux
191
+
192
+ DEPENDENCIES
193
+ appraisal
194
+ html_safe_flash!
195
+ minitest (~> 5.17)
196
+ rails (~> 6.1)
197
+ rake (~> 13.0)
198
+ rubocop-minitest (~> 0.25)
199
+ standard (~> 1.21)
200
+
201
+ BUNDLED WITH
202
+ 2.4.2
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "minitest", "~> 5.17"
6
+ gem "rake", "~> 13.0"
7
+ gem "rubocop-minitest", "~> 0.25"
8
+ gem "standard", "~> 1.21"
9
+ gem "rails", "~> 7.0"
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,201 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ html_safe_flash (0.1.0)
5
+ rails (>= 6)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (7.0.4)
11
+ actionpack (= 7.0.4)
12
+ activesupport (= 7.0.4)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (7.0.4)
16
+ actionpack (= 7.0.4)
17
+ activejob (= 7.0.4)
18
+ activerecord (= 7.0.4)
19
+ activestorage (= 7.0.4)
20
+ activesupport (= 7.0.4)
21
+ mail (>= 2.7.1)
22
+ net-imap
23
+ net-pop
24
+ net-smtp
25
+ actionmailer (7.0.4)
26
+ actionpack (= 7.0.4)
27
+ actionview (= 7.0.4)
28
+ activejob (= 7.0.4)
29
+ activesupport (= 7.0.4)
30
+ mail (~> 2.5, >= 2.5.4)
31
+ net-imap
32
+ net-pop
33
+ net-smtp
34
+ rails-dom-testing (~> 2.0)
35
+ actionpack (7.0.4)
36
+ actionview (= 7.0.4)
37
+ activesupport (= 7.0.4)
38
+ rack (~> 2.0, >= 2.2.0)
39
+ rack-test (>= 0.6.3)
40
+ rails-dom-testing (~> 2.0)
41
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
42
+ actiontext (7.0.4)
43
+ actionpack (= 7.0.4)
44
+ activerecord (= 7.0.4)
45
+ activestorage (= 7.0.4)
46
+ activesupport (= 7.0.4)
47
+ globalid (>= 0.6.0)
48
+ nokogiri (>= 1.8.5)
49
+ actionview (7.0.4)
50
+ activesupport (= 7.0.4)
51
+ builder (~> 3.1)
52
+ erubi (~> 1.4)
53
+ rails-dom-testing (~> 2.0)
54
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
55
+ activejob (7.0.4)
56
+ activesupport (= 7.0.4)
57
+ globalid (>= 0.3.6)
58
+ activemodel (7.0.4)
59
+ activesupport (= 7.0.4)
60
+ activerecord (7.0.4)
61
+ activemodel (= 7.0.4)
62
+ activesupport (= 7.0.4)
63
+ activestorage (7.0.4)
64
+ actionpack (= 7.0.4)
65
+ activejob (= 7.0.4)
66
+ activerecord (= 7.0.4)
67
+ activesupport (= 7.0.4)
68
+ marcel (~> 1.0)
69
+ mini_mime (>= 1.1.0)
70
+ activesupport (7.0.4)
71
+ concurrent-ruby (~> 1.0, >= 1.0.2)
72
+ i18n (>= 1.6, < 2)
73
+ minitest (>= 5.1)
74
+ tzinfo (~> 2.0)
75
+ appraisal (2.4.1)
76
+ bundler
77
+ rake
78
+ thor (>= 0.14.0)
79
+ ast (2.4.2)
80
+ builder (3.2.4)
81
+ concurrent-ruby (1.1.10)
82
+ crass (1.0.6)
83
+ date (3.3.3)
84
+ erubi (1.12.0)
85
+ globalid (1.0.0)
86
+ activesupport (>= 5.0)
87
+ i18n (1.12.0)
88
+ concurrent-ruby (~> 1.0)
89
+ json (2.6.3)
90
+ language_server-protocol (3.17.0.2)
91
+ loofah (2.19.1)
92
+ crass (~> 1.0.2)
93
+ nokogiri (>= 1.5.9)
94
+ mail (2.8.0)
95
+ mini_mime (>= 0.1.1)
96
+ net-imap
97
+ net-pop
98
+ net-smtp
99
+ marcel (1.0.2)
100
+ method_source (1.0.0)
101
+ mini_mime (1.1.2)
102
+ mini_portile2 (2.8.1)
103
+ minitest (5.17.0)
104
+ net-imap (0.3.4)
105
+ date
106
+ net-protocol
107
+ net-pop (0.1.2)
108
+ net-protocol
109
+ net-protocol (0.2.1)
110
+ timeout
111
+ net-smtp (0.3.3)
112
+ net-protocol
113
+ nio4r (2.5.8)
114
+ nokogiri (1.13.10)
115
+ mini_portile2 (~> 2.8.0)
116
+ racc (~> 1.4)
117
+ parallel (1.22.1)
118
+ parser (3.2.0.0)
119
+ ast (~> 2.4.1)
120
+ racc (1.6.2)
121
+ rack (2.2.5)
122
+ rack-test (2.0.2)
123
+ rack (>= 1.3)
124
+ rails (7.0.4)
125
+ actioncable (= 7.0.4)
126
+ actionmailbox (= 7.0.4)
127
+ actionmailer (= 7.0.4)
128
+ actionpack (= 7.0.4)
129
+ actiontext (= 7.0.4)
130
+ actionview (= 7.0.4)
131
+ activejob (= 7.0.4)
132
+ activemodel (= 7.0.4)
133
+ activerecord (= 7.0.4)
134
+ activestorage (= 7.0.4)
135
+ activesupport (= 7.0.4)
136
+ bundler (>= 1.15.0)
137
+ railties (= 7.0.4)
138
+ rails-dom-testing (2.0.3)
139
+ activesupport (>= 4.2.0)
140
+ nokogiri (>= 1.6)
141
+ rails-html-sanitizer (1.4.4)
142
+ loofah (~> 2.19, >= 2.19.1)
143
+ railties (7.0.4)
144
+ actionpack (= 7.0.4)
145
+ activesupport (= 7.0.4)
146
+ method_source
147
+ rake (>= 12.2)
148
+ thor (~> 1.0)
149
+ zeitwerk (~> 2.5)
150
+ rainbow (3.1.1)
151
+ rake (13.0.6)
152
+ regexp_parser (2.6.1)
153
+ rexml (3.2.5)
154
+ rubocop (1.42.0)
155
+ json (~> 2.3)
156
+ parallel (~> 1.10)
157
+ parser (>= 3.1.2.1)
158
+ rainbow (>= 2.2.2, < 4.0)
159
+ regexp_parser (>= 1.8, < 3.0)
160
+ rexml (>= 3.2.5, < 4.0)
161
+ rubocop-ast (>= 1.24.1, < 2.0)
162
+ ruby-progressbar (~> 1.7)
163
+ unicode-display_width (>= 1.4.0, < 3.0)
164
+ rubocop-ast (1.24.1)
165
+ parser (>= 3.1.1.0)
166
+ rubocop-minitest (0.25.1)
167
+ rubocop (>= 0.90, < 2.0)
168
+ rubocop-performance (1.15.2)
169
+ rubocop (>= 1.7.0, < 2.0)
170
+ rubocop-ast (>= 0.4.0)
171
+ ruby-progressbar (1.11.0)
172
+ standard (1.21.1)
173
+ language_server-protocol (~> 3.17.0.2)
174
+ rubocop (= 1.42.0)
175
+ rubocop-performance (= 1.15.2)
176
+ thor (1.2.1)
177
+ timeout (0.3.1)
178
+ tzinfo (2.0.5)
179
+ concurrent-ruby (~> 1.0)
180
+ unicode-display_width (2.4.2)
181
+ websocket-driver (0.7.5)
182
+ websocket-extensions (>= 0.1.0)
183
+ websocket-extensions (0.1.5)
184
+ zeitwerk (2.6.6)
185
+
186
+ PLATFORMS
187
+ ruby
188
+ x86_64-darwin-21
189
+ x86_64-linux
190
+
191
+ DEPENDENCIES
192
+ appraisal
193
+ html_safe_flash!
194
+ minitest (~> 5.17)
195
+ rails (~> 7.0)
196
+ rake (~> 13.0)
197
+ rubocop-minitest (~> 0.25)
198
+ standard (~> 1.21)
199
+
200
+ BUNDLED WITH
201
+ 2.4.2
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "minitest", "~> 5.17"
6
+ gem "rake", "~> 13.0"
7
+ gem "rubocop-minitest", "~> 0.25"
8
+ gem "standard", "~> 1.21"
9
+ gem "rails", github: "rails/rails"
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,207 @@
1
+ GIT
2
+ remote: https://github.com/rails/rails.git
3
+ revision: ed65dfffc109034364ea5f504bc2f74b30f91b7d
4
+ specs:
5
+ actioncable (7.1.0.alpha)
6
+ actionpack (= 7.1.0.alpha)
7
+ activesupport (= 7.1.0.alpha)
8
+ nio4r (~> 2.0)
9
+ websocket-driver (>= 0.6.1)
10
+ zeitwerk (~> 2.6)
11
+ actionmailbox (7.1.0.alpha)
12
+ actionpack (= 7.1.0.alpha)
13
+ activejob (= 7.1.0.alpha)
14
+ activerecord (= 7.1.0.alpha)
15
+ activestorage (= 7.1.0.alpha)
16
+ activesupport (= 7.1.0.alpha)
17
+ mail (>= 2.7.1)
18
+ net-imap
19
+ net-pop
20
+ net-smtp
21
+ actionmailer (7.1.0.alpha)
22
+ actionpack (= 7.1.0.alpha)
23
+ actionview (= 7.1.0.alpha)
24
+ activejob (= 7.1.0.alpha)
25
+ activesupport (= 7.1.0.alpha)
26
+ mail (~> 2.5, >= 2.5.4)
27
+ net-imap
28
+ net-pop
29
+ net-smtp
30
+ rails-dom-testing (~> 2.0)
31
+ actionpack (7.1.0.alpha)
32
+ actionview (= 7.1.0.alpha)
33
+ activesupport (= 7.1.0.alpha)
34
+ rack (~> 2.0, >= 2.2.4)
35
+ rack-test (>= 0.6.3)
36
+ rails-dom-testing (~> 2.0)
37
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
38
+ actiontext (7.1.0.alpha)
39
+ actionpack (= 7.1.0.alpha)
40
+ activerecord (= 7.1.0.alpha)
41
+ activestorage (= 7.1.0.alpha)
42
+ activesupport (= 7.1.0.alpha)
43
+ globalid (>= 0.6.0)
44
+ nokogiri (>= 1.8.5)
45
+ actionview (7.1.0.alpha)
46
+ activesupport (= 7.1.0.alpha)
47
+ builder (~> 3.1)
48
+ erubi (~> 1.11)
49
+ rails-dom-testing (~> 2.0)
50
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
51
+ activejob (7.1.0.alpha)
52
+ activesupport (= 7.1.0.alpha)
53
+ globalid (>= 0.3.6)
54
+ activemodel (7.1.0.alpha)
55
+ activesupport (= 7.1.0.alpha)
56
+ activerecord (7.1.0.alpha)
57
+ activemodel (= 7.1.0.alpha)
58
+ activesupport (= 7.1.0.alpha)
59
+ activestorage (7.1.0.alpha)
60
+ actionpack (= 7.1.0.alpha)
61
+ activejob (= 7.1.0.alpha)
62
+ activerecord (= 7.1.0.alpha)
63
+ activesupport (= 7.1.0.alpha)
64
+ marcel (~> 1.0)
65
+ mini_mime (>= 1.1.0)
66
+ activesupport (7.1.0.alpha)
67
+ concurrent-ruby (~> 1.0, >= 1.0.2)
68
+ connection_pool (>= 2.2.5)
69
+ i18n (>= 1.6, < 2)
70
+ minitest (>= 5.1)
71
+ tzinfo (~> 2.0)
72
+ rails (7.1.0.alpha)
73
+ actioncable (= 7.1.0.alpha)
74
+ actionmailbox (= 7.1.0.alpha)
75
+ actionmailer (= 7.1.0.alpha)
76
+ actionpack (= 7.1.0.alpha)
77
+ actiontext (= 7.1.0.alpha)
78
+ actionview (= 7.1.0.alpha)
79
+ activejob (= 7.1.0.alpha)
80
+ activemodel (= 7.1.0.alpha)
81
+ activerecord (= 7.1.0.alpha)
82
+ activestorage (= 7.1.0.alpha)
83
+ activesupport (= 7.1.0.alpha)
84
+ bundler (>= 1.15.0)
85
+ railties (= 7.1.0.alpha)
86
+ railties (7.1.0.alpha)
87
+ actionpack (= 7.1.0.alpha)
88
+ activesupport (= 7.1.0.alpha)
89
+ rake (>= 12.2)
90
+ thor (~> 1.0)
91
+ zeitwerk (~> 2.6)
92
+
93
+ PATH
94
+ remote: ..
95
+ specs:
96
+ html_safe_flash (0.1.0)
97
+ rails (>= 6)
98
+
99
+ GEM
100
+ remote: https://rubygems.org/
101
+ specs:
102
+ appraisal (2.4.1)
103
+ bundler
104
+ rake
105
+ thor (>= 0.14.0)
106
+ ast (2.4.2)
107
+ builder (3.2.4)
108
+ concurrent-ruby (1.1.10)
109
+ connection_pool (2.3.0)
110
+ crass (1.0.6)
111
+ date (3.3.3)
112
+ erubi (1.12.0)
113
+ globalid (1.0.0)
114
+ activesupport (>= 5.0)
115
+ i18n (1.12.0)
116
+ concurrent-ruby (~> 1.0)
117
+ json (2.6.3)
118
+ language_server-protocol (3.17.0.2)
119
+ loofah (2.19.1)
120
+ crass (~> 1.0.2)
121
+ nokogiri (>= 1.5.9)
122
+ mail (2.8.0)
123
+ mini_mime (>= 0.1.1)
124
+ net-imap
125
+ net-pop
126
+ net-smtp
127
+ marcel (1.0.2)
128
+ mini_mime (1.1.2)
129
+ mini_portile2 (2.8.1)
130
+ minitest (5.17.0)
131
+ net-imap (0.3.4)
132
+ date
133
+ net-protocol
134
+ net-pop (0.1.2)
135
+ net-protocol
136
+ net-protocol (0.2.1)
137
+ timeout
138
+ net-smtp (0.3.3)
139
+ net-protocol
140
+ nio4r (2.5.8)
141
+ nokogiri (1.13.10)
142
+ mini_portile2 (~> 2.8.0)
143
+ racc (~> 1.4)
144
+ parallel (1.22.1)
145
+ parser (3.2.0.0)
146
+ ast (~> 2.4.1)
147
+ racc (1.6.2)
148
+ rack (2.2.5)
149
+ rack-test (2.0.2)
150
+ rack (>= 1.3)
151
+ rails-dom-testing (2.0.3)
152
+ activesupport (>= 4.2.0)
153
+ nokogiri (>= 1.6)
154
+ rails-html-sanitizer (1.4.4)
155
+ loofah (~> 2.19, >= 2.19.1)
156
+ rainbow (3.1.1)
157
+ rake (13.0.6)
158
+ regexp_parser (2.6.1)
159
+ rexml (3.2.5)
160
+ rubocop (1.42.0)
161
+ json (~> 2.3)
162
+ parallel (~> 1.10)
163
+ parser (>= 3.1.2.1)
164
+ rainbow (>= 2.2.2, < 4.0)
165
+ regexp_parser (>= 1.8, < 3.0)
166
+ rexml (>= 3.2.5, < 4.0)
167
+ rubocop-ast (>= 1.24.1, < 2.0)
168
+ ruby-progressbar (~> 1.7)
169
+ unicode-display_width (>= 1.4.0, < 3.0)
170
+ rubocop-ast (1.24.1)
171
+ parser (>= 3.1.1.0)
172
+ rubocop-minitest (0.25.1)
173
+ rubocop (>= 0.90, < 2.0)
174
+ rubocop-performance (1.15.2)
175
+ rubocop (>= 1.7.0, < 2.0)
176
+ rubocop-ast (>= 0.4.0)
177
+ ruby-progressbar (1.11.0)
178
+ standard (1.21.1)
179
+ language_server-protocol (~> 3.17.0.2)
180
+ rubocop (= 1.42.0)
181
+ rubocop-performance (= 1.15.2)
182
+ thor (1.2.1)
183
+ timeout (0.3.1)
184
+ tzinfo (2.0.5)
185
+ concurrent-ruby (~> 1.0)
186
+ unicode-display_width (2.4.2)
187
+ websocket-driver (0.7.5)
188
+ websocket-extensions (>= 0.1.0)
189
+ websocket-extensions (0.1.5)
190
+ zeitwerk (2.6.6)
191
+
192
+ PLATFORMS
193
+ ruby
194
+ x86_64-darwin-21
195
+ x86_64-linux
196
+
197
+ DEPENDENCIES
198
+ appraisal
199
+ html_safe_flash!
200
+ minitest (~> 5.17)
201
+ rails!
202
+ rake (~> 13.0)
203
+ rubocop-minitest (~> 0.25)
204
+ standard (~> 1.21)
205
+
206
+ BUNDLED WITH
207
+ 2.4.2
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/html_safe_flash/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "html_safe_flash"
7
+ spec.version = HtmlSafeFlash::VERSION
8
+ spec.authors = ["Milo Winningham"]
9
+ spec.email = ["milo@winningham.net"]
10
+ spec.summary = "Allows normal usage of html_safe strings in Rails flash messages"
11
+ spec.homepage = "https://github.com/quadule/html_safe_flash"
12
+ spec.license = "MIT"
13
+
14
+ spec.required_ruby_version = ">= 2.7.0"
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = spec.homepage
18
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(__dir__) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
25
+ end
26
+ end
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_dependency "rails", ">= 6"
30
+
31
+ spec.add_development_dependency "appraisal"
32
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/concern"
4
+ require "active_support/core_ext/array/wrap"
5
+ require "active_support/core_ext/module/attribute_accessors_per_thread"
6
+ require "active_support/core_ext/object/try"
7
+
8
+ module HtmlSafeFlash
9
+ module FlashHashExtension
10
+ extend ActiveSupport::Concern
11
+
12
+ prepended do
13
+ thread_mattr_accessor :handle_html_safe_flash, instance_writer: false, default: true
14
+ end
15
+
16
+ class_methods do
17
+ def from_session_value(*)
18
+ super.tap do |flash|
19
+ flash.send(:deserialize_html_safe_values) if handle_html_safe_flash
20
+ end
21
+ end
22
+ end
23
+
24
+ def to_session_value
25
+ serialize_html_safe_values if handle_html_safe_flash
26
+ super
27
+ end
28
+
29
+ private
30
+
31
+ HTML_SAFE_KEYS = "_html_safe_keys"
32
+
33
+ def deserialize_html_safe_values
34
+ Array.wrap(@flashes.delete(HTML_SAFE_KEYS)).each do |key|
35
+ value = @flashes[key]
36
+ if value.respond_to?(:html_safe)
37
+ @flashes[key] = value.html_safe
38
+ end
39
+ end
40
+ end
41
+
42
+ def serialize_html_safe_values
43
+ safe_keys = @flashes.except(*@discard).filter_map do |key, value|
44
+ key if value.is_a?(ActiveSupport::SafeBuffer) && value.html_safe?
45
+ end
46
+
47
+ if safe_keys.empty?
48
+ @flashes.delete(HTML_SAFE_KEYS)
49
+ else
50
+ @flashes[HTML_SAFE_KEYS] = safe_keys
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HtmlSafeFlash
4
+ class Railtie < ::Rails::Railtie
5
+ initializer "html_safe_flash.extend_flash_hash" do
6
+ ActiveSupport.on_load(:action_controller) do
7
+ ActionDispatch::Flash::FlashHash.prepend(FlashHashExtension)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HtmlSafeFlash
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "html_safe_flash/version"
4
+ require "html_safe_flash/flash_hash_extension"
5
+ require "html_safe_flash/railtie" if defined?(Rails::Railtie)
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: html_safe_flash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Milo Winningham
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-01-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: appraisal
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email:
43
+ - milo@winningham.net
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".rubocop.yml"
49
+ - ".ruby-version"
50
+ - ".standard.yml"
51
+ - Appraisals
52
+ - CHANGELOG.md
53
+ - CODE_OF_CONDUCT.md
54
+ - Gemfile
55
+ - Gemfile.lock
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - gemfiles/rails_6.1.gemfile
60
+ - gemfiles/rails_6.1.gemfile.lock
61
+ - gemfiles/rails_7.gemfile
62
+ - gemfiles/rails_7.gemfile.lock
63
+ - gemfiles/rails_main.gemfile
64
+ - gemfiles/rails_main.gemfile.lock
65
+ - html_safe_flash.gemspec
66
+ - lib/html_safe_flash.rb
67
+ - lib/html_safe_flash/flash_hash_extension.rb
68
+ - lib/html_safe_flash/railtie.rb
69
+ - lib/html_safe_flash/version.rb
70
+ homepage: https://github.com/quadule/html_safe_flash
71
+ licenses:
72
+ - MIT
73
+ metadata:
74
+ homepage_uri: https://github.com/quadule/html_safe_flash
75
+ source_code_uri: https://github.com/quadule/html_safe_flash
76
+ changelog_uri: https://github.com/quadule/html_safe_flash/blob/main/CHANGELOG.md
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 2.7.0
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubygems_version: 3.3.7
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Allows normal usage of html_safe strings in Rails flash messages
96
+ test_files: []