konstruo 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +22 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +35 -0
- data/Rakefile +10 -0
- data/lib/konstruo/mapper.rb +120 -0
- data/lib/konstruo/version.rb +6 -0
- data/lib/konstruo.rb +18 -0
- data/sorbet/config +4 -0
- data/sorbet/rbi/annotations/.gitattributes +1 -0
- data/sorbet/rbi/annotations/actionmailer.rbi +10 -0
- data/sorbet/rbi/annotations/actionpack.rbi +430 -0
- data/sorbet/rbi/annotations/actionview.rbi +75 -0
- data/sorbet/rbi/annotations/activejob.rbi +44 -0
- data/sorbet/rbi/annotations/activemodel.rbi +89 -0
- data/sorbet/rbi/annotations/activerecord.rbi +92 -0
- data/sorbet/rbi/annotations/activesupport.rbi +454 -0
- data/sorbet/rbi/annotations/globalid.rbi +30 -0
- data/sorbet/rbi/annotations/minitest.rbi +119 -0
- data/sorbet/rbi/annotations/railties.rbi +61 -0
- data/sorbet/rbi/annotations/rainbow.rbi +269 -0
- data/sorbet/rbi/dsl/.gitattributes +1 -0
- data/sorbet/rbi/dsl/active_support/callbacks.rbi +23 -0
- data/sorbet/rbi/gems/.gitattributes +1 -0
- data/sorbet/rbi/gems/actioncable@7.2.1.rbi +3096 -0
- data/sorbet/rbi/gems/actionmailbox@7.2.1.rbi +1832 -0
- data/sorbet/rbi/gems/actionmailer@7.2.1.rbi +2664 -0
- data/sorbet/rbi/gems/actionpack@7.2.1.rbi +20536 -0
- data/sorbet/rbi/gems/actiontext@7.2.1.rbi +1697 -0
- data/sorbet/rbi/gems/actionview@7.2.1.rbi +15752 -0
- data/sorbet/rbi/gems/activejob@7.2.1.rbi +2828 -0
- data/sorbet/rbi/gems/activemodel@7.2.1.rbi +6762 -0
- data/sorbet/rbi/gems/activerecord@7.2.1.rbi +41433 -0
- data/sorbet/rbi/gems/activestorage@7.2.1.rbi +3247 -0
- data/sorbet/rbi/gems/activesupport@7.2.1.rbi +21142 -0
- data/sorbet/rbi/gems/ast@2.4.2.rbi +585 -0
- data/sorbet/rbi/gems/base64@0.2.0.rbi +509 -0
- data/sorbet/rbi/gems/bigdecimal@3.1.8.rbi +78 -0
- data/sorbet/rbi/gems/builder@3.3.0.rbi +9 -0
- data/sorbet/rbi/gems/concurrent-ruby@1.3.4.rbi +11645 -0
- data/sorbet/rbi/gems/connection_pool@2.4.1.rbi +9 -0
- data/sorbet/rbi/gems/crass@1.0.6.rbi +623 -0
- data/sorbet/rbi/gems/dashbrains-rubocop-config@1.0.4.rbi +9 -0
- data/sorbet/rbi/gems/date@3.3.4.rbi +75 -0
- data/sorbet/rbi/gems/diff-lcs@1.5.1.rbi +1131 -0
- data/sorbet/rbi/gems/drb@2.2.1.rbi +1347 -0
- data/sorbet/rbi/gems/erubi@1.13.0.rbi +150 -0
- data/sorbet/rbi/gems/globalid@1.2.1.rbi +749 -0
- data/sorbet/rbi/gems/i18n@1.14.5.rbi +2359 -0
- data/sorbet/rbi/gems/io-console@0.7.2.rbi +9 -0
- data/sorbet/rbi/gems/json@2.7.2.rbi +1562 -0
- data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +14238 -0
- data/sorbet/rbi/gems/logger@1.6.1.rbi +920 -0
- data/sorbet/rbi/gems/loofah@2.22.0.rbi +1081 -0
- data/sorbet/rbi/gems/mail@2.8.1.rbi +8658 -0
- data/sorbet/rbi/gems/marcel@1.0.4.rbi +239 -0
- data/sorbet/rbi/gems/mini_mime@1.1.5.rbi +173 -0
- data/sorbet/rbi/gems/minitest@5.25.1.rbi +1546 -0
- data/sorbet/rbi/gems/net-imap@0.4.16.rbi +10845 -0
- data/sorbet/rbi/gems/net-pop@0.1.2.rbi +927 -0
- data/sorbet/rbi/gems/net-protocol@0.2.2.rbi +292 -0
- data/sorbet/rbi/gems/net-smtp@0.5.0.rbi +1228 -0
- data/sorbet/rbi/gems/netrc@0.11.0.rbi +159 -0
- data/sorbet/rbi/gems/nio4r@2.7.3.rbi +293 -0
- data/sorbet/rbi/gems/nokogiri@1.16.7.rbi +7311 -0
- data/sorbet/rbi/gems/parallel@1.26.3.rbi +291 -0
- data/sorbet/rbi/gems/parser@3.3.5.0.rbi +5519 -0
- data/sorbet/rbi/gems/prism@1.0.0.rbi +35493 -0
- data/sorbet/rbi/gems/psych@5.1.2.rbi +1769 -0
- data/sorbet/rbi/gems/racc@1.8.1.rbi +162 -0
- data/sorbet/rbi/gems/rack-session@2.0.0.rbi +727 -0
- data/sorbet/rbi/gems/rack-test@2.1.0.rbi +747 -0
- data/sorbet/rbi/gems/rack@3.1.7.rbi +4902 -0
- data/sorbet/rbi/gems/rackup@2.1.0.rbi +390 -0
- data/sorbet/rbi/gems/rails-dom-testing@2.2.0.rbi +758 -0
- data/sorbet/rbi/gems/rails-html-sanitizer@1.6.0.rbi +785 -0
- data/sorbet/rbi/gems/rails@7.2.1.rbi +9 -0
- data/sorbet/rbi/gems/railties@7.2.1.rbi +3824 -0
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +403 -0
- data/sorbet/rbi/gems/rake@13.2.1.rbi +3046 -0
- data/sorbet/rbi/gems/rbi@0.2.0.rbi +4105 -0
- data/sorbet/rbi/gems/rdoc@6.7.0.rbi +12721 -0
- data/sorbet/rbi/gems/regexp_parser@2.9.2.rbi +3772 -0
- data/sorbet/rbi/gems/reline@0.5.10.rbi +9 -0
- data/sorbet/rbi/gems/rspec-core@3.13.1.rbi +11012 -0
- data/sorbet/rbi/gems/rspec-expectations@3.13.3.rbi +8183 -0
- data/sorbet/rbi/gems/rspec-mocks@3.13.1.rbi +5341 -0
- data/sorbet/rbi/gems/rspec-support@3.13.1.rbi +1630 -0
- data/sorbet/rbi/gems/rspec@3.13.0.rbi +83 -0
- data/sorbet/rbi/gems/rubocop-ast@1.32.3.rbi +7446 -0
- data/sorbet/rbi/gems/rubocop-capybara@2.21.0.rbi +9 -0
- data/sorbet/rbi/gems/rubocop-factory_bot@2.26.1.rbi +9 -0
- data/sorbet/rbi/gems/rubocop-graphql@1.5.4.rbi +9 -0
- data/sorbet/rbi/gems/rubocop-minitest@0.36.0.rbi +9 -0
- data/sorbet/rbi/gems/rubocop-performance@1.21.1.rbi +9 -0
- data/sorbet/rbi/gems/rubocop-rails@2.26.1.rbi +9 -0
- data/sorbet/rbi/gems/rubocop-rake@0.6.0.rbi +329 -0
- data/sorbet/rbi/gems/rubocop-rspec@3.0.5.rbi +9 -0
- data/sorbet/rbi/gems/rubocop-rspec_rails@2.30.0.rbi +9 -0
- data/sorbet/rbi/gems/rubocop-sorbet@0.8.5.rbi +9 -0
- data/sorbet/rbi/gems/rubocop@1.66.1.rbi +58268 -0
- data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1318 -0
- data/sorbet/rbi/gems/securerandom@0.3.1.rbi +396 -0
- data/sorbet/rbi/gems/spoom@1.4.2.rbi +4932 -0
- data/sorbet/rbi/gems/stringio@3.1.1.rbi +9 -0
- data/sorbet/rbi/gems/tapioca@0.16.2.rbi +3581 -0
- data/sorbet/rbi/gems/thor@1.3.2.rbi +4378 -0
- data/sorbet/rbi/gems/timeout@0.4.1.rbi +149 -0
- data/sorbet/rbi/gems/tzinfo@2.0.6.rbi +5918 -0
- data/sorbet/rbi/gems/unicode-display_width@2.5.0.rbi +66 -0
- data/sorbet/rbi/gems/useragent@0.16.10.rbi +9 -0
- data/sorbet/rbi/gems/webrick@1.8.1.rbi +2607 -0
- data/sorbet/rbi/gems/websocket-driver@0.7.6.rbi +993 -0
- data/sorbet/rbi/gems/websocket-extensions@0.1.5.rbi +121 -0
- data/sorbet/rbi/gems/yard-sorbet@0.9.0.rbi +435 -0
- data/sorbet/rbi/gems/yard@0.9.37.rbi +18570 -0
- data/sorbet/rbi/gems/zeitwerk@2.6.18.rbi +1051 -0
- data/sorbet/rbi/todo.rbi +6 -0
- data/sorbet/tapioca/config.yml +13 -0
- data/sorbet/tapioca/require.rb +9 -0
- data/tasks/bundle_update.rake +14 -0
- data/tasks/sorbet.rake +26 -0
- metadata +216 -0
@@ -0,0 +1,1081 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This is an autogenerated file for types exported from the `loofah` gem.
|
5
|
+
# Please instead update this file by running `bin/tapioca gem loofah`.
|
6
|
+
|
7
|
+
|
8
|
+
# == Strings and IO Objects as Input
|
9
|
+
#
|
10
|
+
# The following methods accept any IO object in addition to accepting a string:
|
11
|
+
#
|
12
|
+
# - Loofah.html4_document
|
13
|
+
# - Loofah.html4_fragment
|
14
|
+
# - Loofah.scrub_html4_document
|
15
|
+
# - Loofah.scrub_html4_fragment
|
16
|
+
#
|
17
|
+
# - Loofah.html5_document
|
18
|
+
# - Loofah.html5_fragment
|
19
|
+
# - Loofah.scrub_html5_document
|
20
|
+
# - Loofah.scrub_html5_fragment
|
21
|
+
#
|
22
|
+
# - Loofah.xml_document
|
23
|
+
# - Loofah.xml_fragment
|
24
|
+
# - Loofah.scrub_xml_document
|
25
|
+
# - Loofah.scrub_xml_fragment
|
26
|
+
#
|
27
|
+
# - Loofah.document
|
28
|
+
# - Loofah.fragment
|
29
|
+
# - Loofah.scrub_document
|
30
|
+
# - Loofah.scrub_fragment
|
31
|
+
#
|
32
|
+
# That IO object could be a file, or a socket, or a StringIO, or anything that responds to +read+
|
33
|
+
# and +close+.
|
34
|
+
#
|
35
|
+
# source://loofah//lib/loofah.rb#5
|
36
|
+
module Loofah
|
37
|
+
class << self
|
38
|
+
# Shortcut for Loofah::HTML4::Document.parse(*args, &block)
|
39
|
+
#
|
40
|
+
# This method accepts the same parameters as Nokogiri::HTML4::Document.parse
|
41
|
+
#
|
42
|
+
# source://loofah//lib/loofah.rb#76
|
43
|
+
def document(*args, &block); end
|
44
|
+
|
45
|
+
# Shortcut for Loofah::HTML4::DocumentFragment.parse(*args, &block)
|
46
|
+
#
|
47
|
+
# This method accepts the same parameters as Nokogiri::HTML4::DocumentFragment.parse
|
48
|
+
#
|
49
|
+
# source://loofah//lib/loofah.rb#83
|
50
|
+
def fragment(*args, &block); end
|
51
|
+
|
52
|
+
# Shortcut for Loofah::HTML4::Document.parse(*args, &block)
|
53
|
+
#
|
54
|
+
# This method accepts the same parameters as Nokogiri::HTML4::Document.parse
|
55
|
+
#
|
56
|
+
# source://loofah//lib/loofah.rb#76
|
57
|
+
def html4_document(*args, &block); end
|
58
|
+
|
59
|
+
# Shortcut for Loofah::HTML4::DocumentFragment.parse(*args, &block)
|
60
|
+
#
|
61
|
+
# This method accepts the same parameters as Nokogiri::HTML4::DocumentFragment.parse
|
62
|
+
#
|
63
|
+
# source://loofah//lib/loofah.rb#83
|
64
|
+
def html4_fragment(*args, &block); end
|
65
|
+
|
66
|
+
# source://loofah//lib/loofah.rb#101
|
67
|
+
def html5_document(*args, &block); end
|
68
|
+
|
69
|
+
# source://loofah//lib/loofah.rb#108
|
70
|
+
def html5_fragment(*args, &block); end
|
71
|
+
|
72
|
+
# @return [Boolean]
|
73
|
+
#
|
74
|
+
# source://loofah//lib/loofah.rb#7
|
75
|
+
def html5_support?; end
|
76
|
+
|
77
|
+
# A helper to remove extraneous whitespace from text-ified HTML
|
78
|
+
#
|
79
|
+
# source://loofah//lib/loofah.rb#169
|
80
|
+
def remove_extraneous_whitespace(string); end
|
81
|
+
|
82
|
+
# Shortcut for Loofah::HTML4::Document.parse(string_or_io).scrub!(method)
|
83
|
+
#
|
84
|
+
# source://loofah//lib/loofah.rb#88
|
85
|
+
def scrub_document(string_or_io, method); end
|
86
|
+
|
87
|
+
# Shortcut for Loofah::HTML4::DocumentFragment.parse(string_or_io).scrub!(method)
|
88
|
+
#
|
89
|
+
# source://loofah//lib/loofah.rb#93
|
90
|
+
def scrub_fragment(string_or_io, method); end
|
91
|
+
|
92
|
+
# Shortcut for Loofah::HTML4::Document.parse(string_or_io).scrub!(method)
|
93
|
+
#
|
94
|
+
# source://loofah//lib/loofah.rb#88
|
95
|
+
def scrub_html4_document(string_or_io, method); end
|
96
|
+
|
97
|
+
# Shortcut for Loofah::HTML4::DocumentFragment.parse(string_or_io).scrub!(method)
|
98
|
+
#
|
99
|
+
# source://loofah//lib/loofah.rb#93
|
100
|
+
def scrub_html4_fragment(string_or_io, method); end
|
101
|
+
|
102
|
+
# source://loofah//lib/loofah.rb#113
|
103
|
+
def scrub_html5_document(string_or_io, method); end
|
104
|
+
|
105
|
+
# source://loofah//lib/loofah.rb#118
|
106
|
+
def scrub_html5_fragment(string_or_io, method); end
|
107
|
+
|
108
|
+
# Shortcut for Loofah.xml_document(string_or_io).scrub!(method)
|
109
|
+
#
|
110
|
+
# source://loofah//lib/loofah.rb#164
|
111
|
+
def scrub_xml_document(string_or_io, method); end
|
112
|
+
|
113
|
+
# Shortcut for Loofah.xml_fragment(string_or_io).scrub!(method)
|
114
|
+
#
|
115
|
+
# source://loofah//lib/loofah.rb#159
|
116
|
+
def scrub_xml_fragment(string_or_io, method); end
|
117
|
+
|
118
|
+
# Shortcut for Loofah::XML::Document.parse(*args, &block)
|
119
|
+
#
|
120
|
+
# This method accepts the same parameters as Nokogiri::XML::Document.parse
|
121
|
+
#
|
122
|
+
# source://loofah//lib/loofah.rb#147
|
123
|
+
def xml_document(*args, &block); end
|
124
|
+
|
125
|
+
# Shortcut for Loofah::XML::DocumentFragment.parse(*args, &block)
|
126
|
+
#
|
127
|
+
# This method accepts the same parameters as Nokogiri::XML::DocumentFragment.parse
|
128
|
+
#
|
129
|
+
# source://loofah//lib/loofah.rb#154
|
130
|
+
def xml_fragment(*args, &block); end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
# source://loofah//lib/loofah/concerns.rb#125
|
135
|
+
module Loofah::DocumentDecorator
|
136
|
+
# source://loofah//lib/loofah/concerns.rb#126
|
137
|
+
def initialize(*args, &block); end
|
138
|
+
end
|
139
|
+
|
140
|
+
# source://loofah//lib/loofah/elements.rb#6
|
141
|
+
module Loofah::Elements; end
|
142
|
+
|
143
|
+
# source://loofah//lib/loofah/elements.rb#93
|
144
|
+
Loofah::Elements::BLOCK_LEVEL = T.let(T.unsafe(nil), Set)
|
145
|
+
|
146
|
+
# Elements that aren't block but should generate a newline in #to_text
|
147
|
+
#
|
148
|
+
# source://loofah//lib/loofah/elements.rb#90
|
149
|
+
Loofah::Elements::INLINE_LINE_BREAK = T.let(T.unsafe(nil), Set)
|
150
|
+
|
151
|
+
# source://loofah//lib/loofah/elements.rb#94
|
152
|
+
Loofah::Elements::LINEBREAKERS = T.let(T.unsafe(nil), Set)
|
153
|
+
|
154
|
+
# The following elements may also be considered block-level
|
155
|
+
# elements since they may contain block-level elements
|
156
|
+
#
|
157
|
+
# source://loofah//lib/loofah/elements.rb#76
|
158
|
+
Loofah::Elements::LOOSE_BLOCK_LEVEL = T.let(T.unsafe(nil), Set)
|
159
|
+
|
160
|
+
# source://loofah//lib/loofah/elements.rb#92
|
161
|
+
Loofah::Elements::STRICT_BLOCK_LEVEL = T.let(T.unsafe(nil), Set)
|
162
|
+
|
163
|
+
# source://loofah//lib/loofah/elements.rb#7
|
164
|
+
Loofah::Elements::STRICT_BLOCK_LEVEL_HTML4 = T.let(T.unsafe(nil), Set)
|
165
|
+
|
166
|
+
# https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
|
167
|
+
#
|
168
|
+
# source://loofah//lib/loofah/elements.rb#35
|
169
|
+
Loofah::Elements::STRICT_BLOCK_LEVEL_HTML5 = T.let(T.unsafe(nil), Set)
|
170
|
+
|
171
|
+
# Alias for Loofah::HTML4
|
172
|
+
#
|
173
|
+
# source://loofah//lib/loofah.rb#70
|
174
|
+
Loofah::HTML = Loofah::HTML4
|
175
|
+
|
176
|
+
# source://loofah//lib/loofah/html4/document.rb#4
|
177
|
+
module Loofah::HTML4; end
|
178
|
+
|
179
|
+
# Subclass of Nokogiri::HTML4::Document.
|
180
|
+
#
|
181
|
+
# See Loofah::ScrubBehavior and Loofah::TextBehavior for additional methods.
|
182
|
+
#
|
183
|
+
# source://loofah//lib/loofah/html4/document.rb#10
|
184
|
+
class Loofah::HTML4::Document < ::Nokogiri::HTML4::Document
|
185
|
+
include ::Loofah::ScrubBehavior::Node
|
186
|
+
include ::Loofah::DocumentDecorator
|
187
|
+
include ::Loofah::TextBehavior
|
188
|
+
include ::Loofah::HtmlDocumentBehavior
|
189
|
+
extend ::Loofah::HtmlDocumentBehavior::ClassMethods
|
190
|
+
end
|
191
|
+
|
192
|
+
# Subclass of Nokogiri::HTML4::DocumentFragment.
|
193
|
+
#
|
194
|
+
# See Loofah::ScrubBehavior and Loofah::TextBehavior for additional methods.
|
195
|
+
#
|
196
|
+
# source://loofah//lib/loofah/html4/document_fragment.rb#10
|
197
|
+
class Loofah::HTML4::DocumentFragment < ::Nokogiri::HTML4::DocumentFragment
|
198
|
+
include ::Loofah::TextBehavior
|
199
|
+
include ::Loofah::HtmlFragmentBehavior
|
200
|
+
extend ::Loofah::HtmlFragmentBehavior::ClassMethods
|
201
|
+
end
|
202
|
+
|
203
|
+
# source://loofah//lib/loofah/html5/safelist.rb#6
|
204
|
+
module Loofah::HTML5; end
|
205
|
+
|
206
|
+
# Subclass of Nokogiri::HTML5::Document.
|
207
|
+
#
|
208
|
+
# See Loofah::ScrubBehavior and Loofah::TextBehavior for additional methods.
|
209
|
+
#
|
210
|
+
# source://loofah//lib/loofah/html5/document.rb#10
|
211
|
+
class Loofah::HTML5::Document < ::Nokogiri::HTML5::Document
|
212
|
+
include ::Loofah::ScrubBehavior::Node
|
213
|
+
include ::Loofah::DocumentDecorator
|
214
|
+
include ::Loofah::TextBehavior
|
215
|
+
include ::Loofah::HtmlDocumentBehavior
|
216
|
+
extend ::Loofah::HtmlDocumentBehavior::ClassMethods
|
217
|
+
end
|
218
|
+
|
219
|
+
# Subclass of Nokogiri::HTML5::DocumentFragment.
|
220
|
+
#
|
221
|
+
# See Loofah::ScrubBehavior and Loofah::TextBehavior for additional methods.
|
222
|
+
#
|
223
|
+
# source://loofah//lib/loofah/html5/document_fragment.rb#10
|
224
|
+
class Loofah::HTML5::DocumentFragment < ::Nokogiri::HTML5::DocumentFragment
|
225
|
+
include ::Loofah::TextBehavior
|
226
|
+
include ::Loofah::HtmlFragmentBehavior
|
227
|
+
extend ::Loofah::HtmlFragmentBehavior::ClassMethods
|
228
|
+
end
|
229
|
+
|
230
|
+
# source://loofah//lib/loofah/html5/safelist.rb#49
|
231
|
+
module Loofah::HTML5::SafeList; end
|
232
|
+
|
233
|
+
# source://loofah//lib/loofah/html5/safelist.rb#232
|
234
|
+
Loofah::HTML5::SafeList::ACCEPTABLE_ATTRIBUTES = T.let(T.unsafe(nil), Set)
|
235
|
+
|
236
|
+
# https://www.w3.org/TR/css-color-3/#html4
|
237
|
+
#
|
238
|
+
# source://loofah//lib/loofah/html5/safelist.rb#735
|
239
|
+
Loofah::HTML5::SafeList::ACCEPTABLE_CSS_COLORS = T.let(T.unsafe(nil), Set)
|
240
|
+
|
241
|
+
# https://www.w3.org/TR/css-color-3/#svg-color
|
242
|
+
#
|
243
|
+
# source://loofah//lib/loofah/html5/safelist.rb#755
|
244
|
+
Loofah::HTML5::SafeList::ACCEPTABLE_CSS_EXTENDED_COLORS = T.let(T.unsafe(nil), Set)
|
245
|
+
|
246
|
+
# see https://www.quackit.com/css/functions/
|
247
|
+
# omit `url` and `image` from that list
|
248
|
+
#
|
249
|
+
# source://loofah//lib/loofah/html5/safelist.rb#907
|
250
|
+
Loofah::HTML5::SafeList::ACCEPTABLE_CSS_FUNCTIONS = T.let(T.unsafe(nil), Set)
|
251
|
+
|
252
|
+
# source://loofah//lib/loofah/html5/safelist.rb#696
|
253
|
+
Loofah::HTML5::SafeList::ACCEPTABLE_CSS_KEYWORDS = T.let(T.unsafe(nil), Set)
|
254
|
+
|
255
|
+
# source://loofah//lib/loofah/html5/safelist.rb#626
|
256
|
+
Loofah::HTML5::SafeList::ACCEPTABLE_CSS_PROPERTIES = T.let(T.unsafe(nil), Set)
|
257
|
+
|
258
|
+
# source://loofah//lib/loofah/html5/safelist.rb#50
|
259
|
+
Loofah::HTML5::SafeList::ACCEPTABLE_ELEMENTS = T.let(T.unsafe(nil), Set)
|
260
|
+
|
261
|
+
# source://loofah//lib/loofah/html5/safelist.rb#980
|
262
|
+
Loofah::HTML5::SafeList::ACCEPTABLE_PROTOCOLS = T.let(T.unsafe(nil), Set)
|
263
|
+
|
264
|
+
# source://loofah//lib/loofah/html5/safelist.rb#967
|
265
|
+
Loofah::HTML5::SafeList::ACCEPTABLE_SVG_PROPERTIES = T.let(T.unsafe(nil), Set)
|
266
|
+
|
267
|
+
# source://loofah//lib/loofah/html5/safelist.rb#1011
|
268
|
+
Loofah::HTML5::SafeList::ACCEPTABLE_URI_DATA_MEDIATYPES = T.let(T.unsafe(nil), Set)
|
269
|
+
|
270
|
+
# source://loofah//lib/loofah/html5/safelist.rb#1021
|
271
|
+
Loofah::HTML5::SafeList::ALLOWED_ATTRIBUTES = T.let(T.unsafe(nil), Set)
|
272
|
+
|
273
|
+
# source://loofah//lib/loofah/html5/safelist.rb#1024
|
274
|
+
Loofah::HTML5::SafeList::ALLOWED_CSS_FUNCTIONS = T.let(T.unsafe(nil), Set)
|
275
|
+
|
276
|
+
# source://loofah//lib/loofah/html5/safelist.rb#1023
|
277
|
+
Loofah::HTML5::SafeList::ALLOWED_CSS_KEYWORDS = T.let(T.unsafe(nil), Set)
|
278
|
+
|
279
|
+
# source://loofah//lib/loofah/html5/safelist.rb#1022
|
280
|
+
Loofah::HTML5::SafeList::ALLOWED_CSS_PROPERTIES = T.let(T.unsafe(nil), Set)
|
281
|
+
|
282
|
+
# subclasses may define their own versions of these constants
|
283
|
+
#
|
284
|
+
# source://loofah//lib/loofah/html5/safelist.rb#1020
|
285
|
+
Loofah::HTML5::SafeList::ALLOWED_ELEMENTS = T.let(T.unsafe(nil), Set)
|
286
|
+
|
287
|
+
# source://loofah//lib/loofah/html5/safelist.rb#1045
|
288
|
+
Loofah::HTML5::SafeList::ALLOWED_ELEMENTS_WITH_LIBXML2 = T.let(T.unsafe(nil), Set)
|
289
|
+
|
290
|
+
# source://loofah//lib/loofah/html5/safelist.rb#1026
|
291
|
+
Loofah::HTML5::SafeList::ALLOWED_PROTOCOLS = T.let(T.unsafe(nil), Set)
|
292
|
+
|
293
|
+
# source://loofah//lib/loofah/html5/safelist.rb#1025
|
294
|
+
Loofah::HTML5::SafeList::ALLOWED_SVG_PROPERTIES = T.let(T.unsafe(nil), Set)
|
295
|
+
|
296
|
+
# source://loofah//lib/loofah/html5/safelist.rb#1027
|
297
|
+
Loofah::HTML5::SafeList::ALLOWED_URI_DATA_MEDIATYPES = T.let(T.unsafe(nil), Set)
|
298
|
+
|
299
|
+
# source://loofah//lib/loofah/html5/safelist.rb#526
|
300
|
+
Loofah::HTML5::SafeList::ARIA_ATTRIBUTES = T.let(T.unsafe(nil), Set)
|
301
|
+
|
302
|
+
# source://loofah//lib/loofah/html5/safelist.rb#582
|
303
|
+
Loofah::HTML5::SafeList::ATTR_VAL_IS_URI = T.let(T.unsafe(nil), Set)
|
304
|
+
|
305
|
+
# source://loofah//lib/loofah/html5/safelist.rb#315
|
306
|
+
Loofah::HTML5::SafeList::MATHML_ATTRIBUTES = T.let(T.unsafe(nil), Set)
|
307
|
+
|
308
|
+
# source://loofah//lib/loofah/html5/safelist.rb#147
|
309
|
+
Loofah::HTML5::SafeList::MATHML_ELEMENTS = T.let(T.unsafe(nil), Set)
|
310
|
+
|
311
|
+
# source://loofah//lib/loofah/html5/safelist.rb#978
|
312
|
+
Loofah::HTML5::SafeList::PROTOCOL_SEPARATOR = T.let(T.unsafe(nil), Regexp)
|
313
|
+
|
314
|
+
# source://loofah//lib/loofah/html5/safelist.rb#960
|
315
|
+
Loofah::HTML5::SafeList::SHORTHAND_CSS_PROPERTIES = T.let(T.unsafe(nil), Set)
|
316
|
+
|
317
|
+
# source://loofah//lib/loofah/html5/safelist.rb#608
|
318
|
+
Loofah::HTML5::SafeList::SVG_ALLOW_LOCAL_HREF = T.let(T.unsafe(nil), Set)
|
319
|
+
|
320
|
+
# source://loofah//lib/loofah/html5/safelist.rb#367
|
321
|
+
Loofah::HTML5::SafeList::SVG_ATTRIBUTES = T.let(T.unsafe(nil), Set)
|
322
|
+
|
323
|
+
# source://loofah//lib/loofah/html5/safelist.rb#594
|
324
|
+
Loofah::HTML5::SafeList::SVG_ATTR_VAL_ALLOWS_REF = T.let(T.unsafe(nil), Set)
|
325
|
+
|
326
|
+
# source://loofah//lib/loofah/html5/safelist.rb#183
|
327
|
+
Loofah::HTML5::SafeList::SVG_ELEMENTS = T.let(T.unsafe(nil), Set)
|
328
|
+
|
329
|
+
# additional tags we should consider safe since we have libxml2 fixing up our documents.
|
330
|
+
#
|
331
|
+
# source://loofah//lib/loofah/html5/safelist.rb#1040
|
332
|
+
Loofah::HTML5::SafeList::TAGS_SAFE_WITH_LIBXML2 = T.let(T.unsafe(nil), Set)
|
333
|
+
|
334
|
+
# TODO: remove VOID_ELEMENTS in a future major release
|
335
|
+
# and put it in the tests (it is used only for testing, not for functional behavior)
|
336
|
+
#
|
337
|
+
# source://loofah//lib/loofah/html5/safelist.rb#1031
|
338
|
+
Loofah::HTML5::SafeList::VOID_ELEMENTS = T.let(T.unsafe(nil), Set)
|
339
|
+
|
340
|
+
# source://loofah//lib/loofah/html5/scrub.rb#8
|
341
|
+
module Loofah::HTML5::Scrub
|
342
|
+
class << self
|
343
|
+
# @return [Boolean]
|
344
|
+
#
|
345
|
+
# source://loofah//lib/loofah/html5/scrub.rb#18
|
346
|
+
def allowed_element?(element_name); end
|
347
|
+
|
348
|
+
# source://loofah//lib/loofah/html5/scrub.rb#192
|
349
|
+
def cdata_escape(node); end
|
350
|
+
|
351
|
+
# @return [Boolean]
|
352
|
+
#
|
353
|
+
# source://loofah//lib/loofah/html5/scrub.rb#187
|
354
|
+
def cdata_needs_escaping?(node); end
|
355
|
+
|
356
|
+
# source://loofah//lib/loofah/html5/scrub.rb#207
|
357
|
+
def escape_tags(string); end
|
358
|
+
|
359
|
+
# libxml2 >= 2.9.2 fails to escape comments within some attributes.
|
360
|
+
#
|
361
|
+
# see comments about CVE-2018-8048 within the tests for more information
|
362
|
+
#
|
363
|
+
# source://loofah//lib/loofah/html5/scrub.rb#166
|
364
|
+
def force_correct_attribute_escaping!(node); end
|
365
|
+
|
366
|
+
# source://loofah//lib/loofah/html5/scrub.rb#123
|
367
|
+
def scrub_attribute_that_allows_local_ref(attr_node); end
|
368
|
+
|
369
|
+
# alternative implementation of the html5lib attribute scrubbing algorithm
|
370
|
+
#
|
371
|
+
# source://loofah//lib/loofah/html5/scrub.rb#23
|
372
|
+
def scrub_attributes(node); end
|
373
|
+
|
374
|
+
# source://loofah//lib/loofah/html5/scrub.rb#72
|
375
|
+
def scrub_css(style); end
|
376
|
+
|
377
|
+
# source://loofah//lib/loofah/html5/scrub.rb#67
|
378
|
+
def scrub_css_attribute(node); end
|
379
|
+
|
380
|
+
# source://loofah//lib/loofah/html5/scrub.rb#142
|
381
|
+
def scrub_uri_attribute(attr_node); end
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
# source://loofah//lib/loofah/html5/scrub.rb#9
|
386
|
+
Loofah::HTML5::Scrub::CONTROL_CHARACTERS = T.let(T.unsafe(nil), Regexp)
|
387
|
+
|
388
|
+
# source://loofah//lib/loofah/html5/scrub.rb#11
|
389
|
+
Loofah::HTML5::Scrub::CRASS_SEMICOLON = T.let(T.unsafe(nil), Hash)
|
390
|
+
|
391
|
+
# source://loofah//lib/loofah/html5/scrub.rb#12
|
392
|
+
Loofah::HTML5::Scrub::CSS_IMPORTANT = T.let(T.unsafe(nil), String)
|
393
|
+
|
394
|
+
# source://loofah//lib/loofah/html5/scrub.rb#10
|
395
|
+
Loofah::HTML5::Scrub::CSS_KEYWORDISH = T.let(T.unsafe(nil), Regexp)
|
396
|
+
|
397
|
+
# source://loofah//lib/loofah/html5/scrub.rb#14
|
398
|
+
Loofah::HTML5::Scrub::CSS_PROPERTY_STRING_WITHOUT_EMBEDDED_QUOTES = T.let(T.unsafe(nil), Regexp)
|
399
|
+
|
400
|
+
# source://loofah//lib/loofah/html5/scrub.rb#13
|
401
|
+
Loofah::HTML5::Scrub::CSS_WHITESPACE = T.let(T.unsafe(nil), String)
|
402
|
+
|
403
|
+
# source://loofah//lib/loofah/html5/scrub.rb#15
|
404
|
+
Loofah::HTML5::Scrub::DATA_ATTRIBUTE_NAME = T.let(T.unsafe(nil), Regexp)
|
405
|
+
|
406
|
+
# source://loofah//lib/loofah/html5/safelist.rb#1048
|
407
|
+
Loofah::HTML5::WhiteList = Loofah::HTML5::SafeList
|
408
|
+
|
409
|
+
# source://loofah//lib/loofah/concerns.rb#133
|
410
|
+
module Loofah::HtmlDocumentBehavior
|
411
|
+
mixes_in_class_methods ::Loofah::HtmlDocumentBehavior::ClassMethods
|
412
|
+
|
413
|
+
# source://loofah//lib/loofah/concerns.rb#164
|
414
|
+
def serialize_root; end
|
415
|
+
|
416
|
+
class << self
|
417
|
+
# @private
|
418
|
+
#
|
419
|
+
# source://loofah//lib/loofah/concerns.rb#159
|
420
|
+
def included(base); end
|
421
|
+
end
|
422
|
+
end
|
423
|
+
|
424
|
+
# source://loofah//lib/loofah/concerns.rb#134
|
425
|
+
module Loofah::HtmlDocumentBehavior::ClassMethods
|
426
|
+
# source://loofah//lib/loofah/concerns.rb#135
|
427
|
+
def parse(*args, &block); end
|
428
|
+
|
429
|
+
private
|
430
|
+
|
431
|
+
# remove comments that exist outside of the HTML element.
|
432
|
+
#
|
433
|
+
# these comments are allowed by the HTML spec:
|
434
|
+
#
|
435
|
+
# https://www.w3.org/TR/html401/struct/global.html#h-7.1
|
436
|
+
#
|
437
|
+
# but are not scrubbed by Loofah because these nodes don't meet
|
438
|
+
# the contract that scrubbers expect of a node (e.g., it can be
|
439
|
+
# replaced, sibling and children nodes can be created).
|
440
|
+
#
|
441
|
+
# source://loofah//lib/loofah/concerns.rb#150
|
442
|
+
def remove_comments_before_html_element(doc); end
|
443
|
+
end
|
444
|
+
|
445
|
+
# source://loofah//lib/loofah/concerns.rb#169
|
446
|
+
module Loofah::HtmlFragmentBehavior
|
447
|
+
mixes_in_class_methods ::Loofah::HtmlFragmentBehavior::ClassMethods
|
448
|
+
|
449
|
+
# source://loofah//lib/loofah/concerns.rb#197
|
450
|
+
def serialize; end
|
451
|
+
|
452
|
+
# source://loofah//lib/loofah/concerns.rb#203
|
453
|
+
def serialize_root; end
|
454
|
+
|
455
|
+
# source://loofah//lib/loofah/concerns.rb#197
|
456
|
+
def to_s; end
|
457
|
+
|
458
|
+
class << self
|
459
|
+
# @private
|
460
|
+
#
|
461
|
+
# source://loofah//lib/loofah/concerns.rb#192
|
462
|
+
def included(base); end
|
463
|
+
end
|
464
|
+
end
|
465
|
+
|
466
|
+
# source://loofah//lib/loofah/concerns.rb#170
|
467
|
+
module Loofah::HtmlFragmentBehavior::ClassMethods
|
468
|
+
# source://loofah//lib/loofah/concerns.rb#180
|
469
|
+
def document_klass; end
|
470
|
+
|
471
|
+
# source://loofah//lib/loofah/concerns.rb#171
|
472
|
+
def parse(tags, encoding = T.unsafe(nil)); end
|
473
|
+
end
|
474
|
+
|
475
|
+
# constants related to working around unhelpful libxml2 behavior
|
476
|
+
#
|
477
|
+
# ಠ_ಠ
|
478
|
+
#
|
479
|
+
# source://loofah//lib/loofah/html5/libxml2_workarounds.rb#12
|
480
|
+
module Loofah::LibxmlWorkarounds; end
|
481
|
+
|
482
|
+
# these attributes and qualifying parent tags are determined by the code at:
|
483
|
+
#
|
484
|
+
# https://git.gnome.org/browse/libxml2/tree/HTMLtree.c?h=v2.9.2#n714
|
485
|
+
#
|
486
|
+
# see comments about CVE-2018-8048 within the tests for more information
|
487
|
+
#
|
488
|
+
# source://loofah//lib/loofah/html5/libxml2_workarounds.rb#20
|
489
|
+
Loofah::LibxmlWorkarounds::BROKEN_ESCAPING_ATTRIBUTES = T.let(T.unsafe(nil), Set)
|
490
|
+
|
491
|
+
# source://loofah//lib/loofah/html5/libxml2_workarounds.rb#26
|
492
|
+
Loofah::LibxmlWorkarounds::BROKEN_ESCAPING_ATTRIBUTES_QUALIFYING_TAG = T.let(T.unsafe(nil), Hash)
|
493
|
+
|
494
|
+
# source://loofah//lib/loofah/metahelpers.rb#4
|
495
|
+
module Loofah::MetaHelpers
|
496
|
+
class << self
|
497
|
+
# source://loofah//lib/loofah/metahelpers.rb#6
|
498
|
+
def add_downcased_set_members_to_all_set_constants(mojule); end
|
499
|
+
end
|
500
|
+
end
|
501
|
+
|
502
|
+
# Mixes +scrub!+ into Document, DocumentFragment, Node and NodeSet.
|
503
|
+
#
|
504
|
+
# Traverse the document or fragment, invoking the +scrubber+ on each node.
|
505
|
+
#
|
506
|
+
# +scrubber+ must either be one of the symbols representing the built-in scrubbers (see
|
507
|
+
# Scrubbers), or a Scrubber instance.
|
508
|
+
#
|
509
|
+
# span2div = Loofah::Scrubber.new do |node|
|
510
|
+
# node.name = "div" if node.name == "span"
|
511
|
+
# end
|
512
|
+
# Loofah.html5_fragment("<span>foo</span><p>bar</p>").scrub!(span2div).to_s
|
513
|
+
# # => "<div>foo</div><p>bar</p>"
|
514
|
+
#
|
515
|
+
# or
|
516
|
+
#
|
517
|
+
# unsafe_html = "ohai! <div>div is safe</div> <script>but script is not</script>"
|
518
|
+
# Loofah.html5_fragment(unsafe_html).scrub!(:strip).to_s
|
519
|
+
# # => "ohai! <div>div is safe</div> "
|
520
|
+
#
|
521
|
+
# Note that this method is called implicitly from the shortcuts Loofah.scrub_html5_fragment et
|
522
|
+
# al.
|
523
|
+
#
|
524
|
+
# Please see Scrubber for more information on implementation and traversal, and README.rdoc for
|
525
|
+
# more example usage.
|
526
|
+
#
|
527
|
+
# source://loofah//lib/loofah/concerns.rb#30
|
528
|
+
module Loofah::ScrubBehavior
|
529
|
+
class << self
|
530
|
+
# source://loofah//lib/loofah/concerns.rb#59
|
531
|
+
def resolve_scrubber(scrubber); end
|
532
|
+
end
|
533
|
+
end
|
534
|
+
|
535
|
+
# source://loofah//lib/loofah/concerns.rb#31
|
536
|
+
module Loofah::ScrubBehavior::Node
|
537
|
+
# source://loofah//lib/loofah/concerns.rb#32
|
538
|
+
def scrub!(scrubber); end
|
539
|
+
end
|
540
|
+
|
541
|
+
# source://loofah//lib/loofah/concerns.rb#51
|
542
|
+
module Loofah::ScrubBehavior::NodeSet
|
543
|
+
# source://loofah//lib/loofah/concerns.rb#52
|
544
|
+
def scrub!(scrubber); end
|
545
|
+
end
|
546
|
+
|
547
|
+
# A Scrubber wraps up a block (or method) that is run on an HTML node (element):
|
548
|
+
#
|
549
|
+
# # change all <span> tags to <div> tags
|
550
|
+
# span2div = Loofah::Scrubber.new do |node|
|
551
|
+
# node.name = "div" if node.name == "span"
|
552
|
+
# end
|
553
|
+
#
|
554
|
+
# Alternatively, this scrubber could have been implemented as:
|
555
|
+
#
|
556
|
+
# class Span2Div < Loofah::Scrubber
|
557
|
+
# def scrub(node)
|
558
|
+
# node.name = "div" if node.name == "span"
|
559
|
+
# end
|
560
|
+
# end
|
561
|
+
# span2div = Span2Div.new
|
562
|
+
#
|
563
|
+
# This can then be run on a document:
|
564
|
+
#
|
565
|
+
# Loofah.html5_fragment("<span>foo</span><p>bar</p>").scrub!(span2div).to_s
|
566
|
+
# # => "<div>foo</div><p>bar</p>"
|
567
|
+
#
|
568
|
+
# Scrubbers can be run on a document in either a top-down traversal (the
|
569
|
+
# default) or bottom-up. Top-down scrubbers can optionally return
|
570
|
+
# Scrubber::STOP to terminate the traversal of a subtree.
|
571
|
+
#
|
572
|
+
# source://loofah//lib/loofah/scrubber.rb#35
|
573
|
+
class Loofah::Scrubber
|
574
|
+
# Options may include
|
575
|
+
# :direction => :top_down (the default)
|
576
|
+
# or
|
577
|
+
# :direction => :bottom_up
|
578
|
+
#
|
579
|
+
# For top_down traversals, if the block returns
|
580
|
+
# Loofah::Scrubber::STOP, then the traversal will be terminated
|
581
|
+
# for the current node's subtree.
|
582
|
+
#
|
583
|
+
# Alternatively, a Scrubber may inherit from Loofah::Scrubber,
|
584
|
+
# and implement +scrub+, which is slightly faster than using a
|
585
|
+
# block.
|
586
|
+
#
|
587
|
+
# @return [Scrubber] a new instance of Scrubber
|
588
|
+
#
|
589
|
+
# source://loofah//lib/loofah/scrubber.rb#65
|
590
|
+
def initialize(options = T.unsafe(nil), &block); end
|
591
|
+
|
592
|
+
# If the attribute is not set, add it
|
593
|
+
# If the attribute is set, don't overwrite the existing value
|
594
|
+
#
|
595
|
+
# source://loofah//lib/loofah/scrubber.rb#96
|
596
|
+
def append_attribute(node, attribute, value); end
|
597
|
+
|
598
|
+
# When a scrubber is initialized, the optional block is saved as
|
599
|
+
# :block. Note that, if no block is passed, then the +scrub+
|
600
|
+
# method is assumed to have been implemented.
|
601
|
+
#
|
602
|
+
# source://loofah//lib/loofah/scrubber.rb#49
|
603
|
+
def block; end
|
604
|
+
|
605
|
+
# When a scrubber is initialized, the :direction may be specified
|
606
|
+
# as :top_down (the default) or :bottom_up.
|
607
|
+
#
|
608
|
+
# source://loofah//lib/loofah/scrubber.rb#44
|
609
|
+
def direction; end
|
610
|
+
|
611
|
+
# When +new+ is not passed a block, the class may implement
|
612
|
+
# +scrub+, which will be called for each document node.
|
613
|
+
#
|
614
|
+
# @raise [ScrubberNotFound]
|
615
|
+
#
|
616
|
+
# source://loofah//lib/loofah/scrubber.rb#88
|
617
|
+
def scrub(node); end
|
618
|
+
|
619
|
+
# Calling +traverse+ will cause the document to be traversed by
|
620
|
+
# either the lambda passed to the initializer or the +scrub+
|
621
|
+
# method, in the direction specified at +new+ time.
|
622
|
+
#
|
623
|
+
# source://loofah//lib/loofah/scrubber.rb#80
|
624
|
+
def traverse(node); end
|
625
|
+
|
626
|
+
private
|
627
|
+
|
628
|
+
# source://loofah//lib/loofah/scrubber.rb#105
|
629
|
+
def html5lib_sanitize(node); end
|
630
|
+
|
631
|
+
# source://loofah//lib/loofah/scrubber.rb#131
|
632
|
+
def traverse_conditionally_bottom_up(node); end
|
633
|
+
|
634
|
+
# source://loofah//lib/loofah/scrubber.rb#122
|
635
|
+
def traverse_conditionally_top_down(node); end
|
636
|
+
end
|
637
|
+
|
638
|
+
# Top-down Scrubbers may return CONTINUE to indicate that the subtree should be traversed.
|
639
|
+
#
|
640
|
+
# source://loofah//lib/loofah/scrubber.rb#37
|
641
|
+
Loofah::Scrubber::CONTINUE = T.let(T.unsafe(nil), Object)
|
642
|
+
|
643
|
+
# Top-down Scrubbers may return STOP to indicate that the subtree should not be traversed.
|
644
|
+
#
|
645
|
+
# source://loofah//lib/loofah/scrubber.rb#40
|
646
|
+
Loofah::Scrubber::STOP = T.let(T.unsafe(nil), Object)
|
647
|
+
|
648
|
+
# A RuntimeError raised when Loofah could not find an appropriate scrubber.
|
649
|
+
#
|
650
|
+
# source://loofah//lib/loofah/scrubber.rb#7
|
651
|
+
class Loofah::ScrubberNotFound < ::RuntimeError; end
|
652
|
+
|
653
|
+
# Loofah provides some built-in scrubbers for sanitizing with
|
654
|
+
# HTML5lib's safelist and for accomplishing some common
|
655
|
+
# transformation tasks.
|
656
|
+
#
|
657
|
+
#
|
658
|
+
# === Loofah::Scrubbers::Strip / scrub!(:strip)
|
659
|
+
#
|
660
|
+
# +:strip+ removes unknown/unsafe tags, but leaves behind the pristine contents:
|
661
|
+
#
|
662
|
+
# unsafe_html = "ohai! <div>div is safe</div> <foo>but foo is <b>not</b></foo>"
|
663
|
+
# Loofah.html5_fragment(unsafe_html).scrub!(:strip)
|
664
|
+
# => "ohai! <div>div is safe</div> but foo is <b>not</b>"
|
665
|
+
#
|
666
|
+
#
|
667
|
+
# === Loofah::Scrubbers::Prune / scrub!(:prune)
|
668
|
+
#
|
669
|
+
# +:prune+ removes unknown/unsafe tags and their contents (including their subtrees):
|
670
|
+
#
|
671
|
+
# unsafe_html = "ohai! <div>div is safe</div> <foo>but foo is <b>not</b></foo>"
|
672
|
+
# Loofah.html5_fragment(unsafe_html).scrub!(:prune)
|
673
|
+
# => "ohai! <div>div is safe</div> "
|
674
|
+
#
|
675
|
+
#
|
676
|
+
# === Loofah::Scrubbers::Escape / scrub!(:escape)
|
677
|
+
#
|
678
|
+
# +:escape+ performs HTML entity escaping on the unknown/unsafe tags:
|
679
|
+
#
|
680
|
+
# unsafe_html = "ohai! <div>div is safe</div> <foo>but foo is <b>not</b></foo>"
|
681
|
+
# Loofah.html5_fragment(unsafe_html).scrub!(:escape)
|
682
|
+
# => "ohai! <div>div is safe</div> <foo>but foo is <b>not</b></foo>"
|
683
|
+
#
|
684
|
+
#
|
685
|
+
# === Loofah::Scrubbers::Whitewash / scrub!(:whitewash)
|
686
|
+
#
|
687
|
+
# +:whitewash+ removes all comments, styling and attributes in
|
688
|
+
# addition to doing markup-fixer-uppery and pruning unsafe tags. I
|
689
|
+
# like to call this "whitewashing", since it's like putting a new
|
690
|
+
# layer of paint on top of the HTML input to make it look nice.
|
691
|
+
#
|
692
|
+
# messy_markup = "ohai! <div id='foo' class='bar' style='margin: 10px'>div with attributes</div>"
|
693
|
+
# Loofah.html5_fragment(messy_markup).scrub!(:whitewash)
|
694
|
+
# => "ohai! <div>div with attributes</div>"
|
695
|
+
#
|
696
|
+
# One use case for this scrubber is to clean up HTML that was
|
697
|
+
# cut-and-pasted from Microsoft Word into a WYSIWYG editor or a
|
698
|
+
# rich text editor. Microsoft's software is famous for injecting
|
699
|
+
# all kinds of cruft into its HTML output. Who needs that crap?
|
700
|
+
# Certainly not me.
|
701
|
+
#
|
702
|
+
#
|
703
|
+
# === Loofah::Scrubbers::NoFollow / scrub!(:nofollow)
|
704
|
+
#
|
705
|
+
# +:nofollow+ adds a rel="nofollow" attribute to all links
|
706
|
+
#
|
707
|
+
# link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
|
708
|
+
# Loofah.html5_fragment(link_farmers_markup).scrub!(:nofollow)
|
709
|
+
# => "ohai! <a href='http://www.myswarmysite.com/' rel="nofollow">I like your blog post</a>"
|
710
|
+
#
|
711
|
+
#
|
712
|
+
# === Loofah::Scrubbers::TargetBlank / scrub!(:targetblank)
|
713
|
+
#
|
714
|
+
# +:targetblank+ adds a target="_blank" attribute to all links
|
715
|
+
#
|
716
|
+
# link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
|
717
|
+
# Loofah.html5_fragment(link_farmers_markup).scrub!(:targetblank)
|
718
|
+
# => "ohai! <a href='http://www.myswarmysite.com/' target="_blank">I like your blog post</a>"
|
719
|
+
#
|
720
|
+
#
|
721
|
+
# === Loofah::Scrubbers::NoOpener / scrub!(:noopener)
|
722
|
+
#
|
723
|
+
# +:noopener+ adds a rel="noopener" attribute to all links
|
724
|
+
#
|
725
|
+
# link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
|
726
|
+
# Loofah.html5_fragment(link_farmers_markup).scrub!(:noopener)
|
727
|
+
# => "ohai! <a href='http://www.myswarmysite.com/' rel="noopener">I like your blog post</a>"
|
728
|
+
#
|
729
|
+
# === Loofah::Scrubbers::NoReferrer / scrub!(:noreferrer)
|
730
|
+
#
|
731
|
+
# +:noreferrer+ adds a rel="noreferrer" attribute to all links
|
732
|
+
#
|
733
|
+
# link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
|
734
|
+
# Loofah.html5_fragment(link_farmers_markup).scrub!(:noreferrer)
|
735
|
+
# => "ohai! <a href='http://www.myswarmysite.com/' rel="noreferrer">I like your blog post</a>"
|
736
|
+
#
|
737
|
+
#
|
738
|
+
# === Loofah::Scrubbers::Unprintable / scrub!(:unprintable)
|
739
|
+
#
|
740
|
+
# +:unprintable+ removes unprintable Unicode characters.
|
741
|
+
#
|
742
|
+
# markup = "<p>Some text with an unprintable character at the end\u2028</p>"
|
743
|
+
# Loofah.html5_fragment(markup).scrub!(:unprintable)
|
744
|
+
# => "<p>Some text with an unprintable character at the end</p>"
|
745
|
+
#
|
746
|
+
# You may not be able to see the unprintable character in the above example, but there is a
|
747
|
+
# U+2028 character right before the closing </p> tag. These characters can cause issues if
|
748
|
+
# the content is ever parsed by JavaScript - more information here:
|
749
|
+
#
|
750
|
+
# http://timelessrepo.com/json-isnt-a-javascript-subset
|
751
|
+
#
|
752
|
+
# source://loofah//lib/loofah/scrubbers.rb#104
|
753
|
+
module Loofah::Scrubbers
|
754
|
+
class << self
|
755
|
+
# Returns an array of symbols representing the built-in scrubbers
|
756
|
+
#
|
757
|
+
# source://loofah//lib/loofah/scrubbers.rb#371
|
758
|
+
def scrubber_symbols; end
|
759
|
+
end
|
760
|
+
end
|
761
|
+
|
762
|
+
# === scrub!(:escape)
|
763
|
+
#
|
764
|
+
# +:escape+ performs HTML entity escaping on the unknown/unsafe tags:
|
765
|
+
#
|
766
|
+
# unsafe_html = "ohai! <div>div is safe</div> <foo>but foo is <b>not</b></foo>"
|
767
|
+
# Loofah.html5_fragment(unsafe_html).scrub!(:escape)
|
768
|
+
# => "ohai! <div>div is safe</div> <foo>but foo is <b>not</b></foo>"
|
769
|
+
#
|
770
|
+
# source://loofah//lib/loofah/scrubbers.rb#159
|
771
|
+
class Loofah::Scrubbers::Escape < ::Loofah::Scrubber
|
772
|
+
# @return [Escape] a new instance of Escape
|
773
|
+
#
|
774
|
+
# source://loofah//lib/loofah/scrubbers.rb#160
|
775
|
+
def initialize; end
|
776
|
+
|
777
|
+
# source://loofah//lib/loofah/scrubbers.rb#164
|
778
|
+
def scrub(node); end
|
779
|
+
end
|
780
|
+
|
781
|
+
# A hash that maps a symbol (like +:prune+) to the appropriate Scrubber (Loofah::Scrubbers::Prune).
|
782
|
+
#
|
783
|
+
# source://loofah//lib/loofah/scrubbers.rb#354
|
784
|
+
Loofah::Scrubbers::MAP = T.let(T.unsafe(nil), Hash)
|
785
|
+
|
786
|
+
# This class probably isn't useful publicly, but is used for #to_text's current implemention
|
787
|
+
#
|
788
|
+
# source://loofah//lib/loofah/scrubbers.rb#305
|
789
|
+
class Loofah::Scrubbers::NewlineBlockElements < ::Loofah::Scrubber
|
790
|
+
# @return [NewlineBlockElements] a new instance of NewlineBlockElements
|
791
|
+
#
|
792
|
+
# source://loofah//lib/loofah/scrubbers.rb#306
|
793
|
+
def initialize; end
|
794
|
+
|
795
|
+
# source://loofah//lib/loofah/scrubbers.rb#310
|
796
|
+
def scrub(node); end
|
797
|
+
end
|
798
|
+
|
799
|
+
# === scrub!(:nofollow)
|
800
|
+
#
|
801
|
+
# +:nofollow+ adds a rel="nofollow" attribute to all links
|
802
|
+
#
|
803
|
+
# link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
|
804
|
+
# Loofah.html5_fragment(link_farmers_markup).scrub!(:nofollow)
|
805
|
+
# => "ohai! <a href='http://www.myswarmysite.com/' rel="nofollow">I like your blog post</a>"
|
806
|
+
#
|
807
|
+
# source://loofah//lib/loofah/scrubbers.rb#220
|
808
|
+
class Loofah::Scrubbers::NoFollow < ::Loofah::Scrubber
|
809
|
+
# @return [NoFollow] a new instance of NoFollow
|
810
|
+
#
|
811
|
+
# source://loofah//lib/loofah/scrubbers.rb#221
|
812
|
+
def initialize; end
|
813
|
+
|
814
|
+
# source://loofah//lib/loofah/scrubbers.rb#225
|
815
|
+
def scrub(node); end
|
816
|
+
end
|
817
|
+
|
818
|
+
# === scrub!(:noopener)
|
819
|
+
#
|
820
|
+
# +:noopener+ adds a rel="noopener" attribute to all links
|
821
|
+
#
|
822
|
+
# link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
|
823
|
+
# Loofah.html5_fragment(link_farmers_markup).scrub!(:noopener)
|
824
|
+
# => "ohai! <a href='http://www.myswarmysite.com/' rel="noopener">I like your blog post</a>"
|
825
|
+
#
|
826
|
+
# source://loofah//lib/loofah/scrubbers.rb#269
|
827
|
+
class Loofah::Scrubbers::NoOpener < ::Loofah::Scrubber
|
828
|
+
# @return [NoOpener] a new instance of NoOpener
|
829
|
+
#
|
830
|
+
# source://loofah//lib/loofah/scrubbers.rb#270
|
831
|
+
def initialize; end
|
832
|
+
|
833
|
+
# source://loofah//lib/loofah/scrubbers.rb#274
|
834
|
+
def scrub(node); end
|
835
|
+
end
|
836
|
+
|
837
|
+
# === scrub!(:noreferrer)
|
838
|
+
#
|
839
|
+
# +:noreferrer+ adds a rel="noreferrer" attribute to all links
|
840
|
+
#
|
841
|
+
# link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
|
842
|
+
# Loofah.html5_fragment(link_farmers_markup).scrub!(:noreferrer)
|
843
|
+
# => "ohai! <a href='http://www.myswarmysite.com/' rel="noreferrer">I like your blog post</a>"
|
844
|
+
#
|
845
|
+
# source://loofah//lib/loofah/scrubbers.rb#291
|
846
|
+
class Loofah::Scrubbers::NoReferrer < ::Loofah::Scrubber
|
847
|
+
# @return [NoReferrer] a new instance of NoReferrer
|
848
|
+
#
|
849
|
+
# source://loofah//lib/loofah/scrubbers.rb#292
|
850
|
+
def initialize; end
|
851
|
+
|
852
|
+
# source://loofah//lib/loofah/scrubbers.rb#296
|
853
|
+
def scrub(node); end
|
854
|
+
end
|
855
|
+
|
856
|
+
# === scrub!(:prune)
|
857
|
+
#
|
858
|
+
# +:prune+ removes unknown/unsafe tags and their contents (including their subtrees):
|
859
|
+
#
|
860
|
+
# unsafe_html = "ohai! <div>div is safe</div> <foo>but foo is <b>not</b></foo>"
|
861
|
+
# Loofah.html5_fragment(unsafe_html).scrub!(:prune)
|
862
|
+
# => "ohai! <div>div is safe</div> "
|
863
|
+
#
|
864
|
+
# source://loofah//lib/loofah/scrubbers.rb#137
|
865
|
+
class Loofah::Scrubbers::Prune < ::Loofah::Scrubber
|
866
|
+
# @return [Prune] a new instance of Prune
|
867
|
+
#
|
868
|
+
# source://loofah//lib/loofah/scrubbers.rb#138
|
869
|
+
def initialize; end
|
870
|
+
|
871
|
+
# source://loofah//lib/loofah/scrubbers.rb#142
|
872
|
+
def scrub(node); end
|
873
|
+
end
|
874
|
+
|
875
|
+
# === scrub!(:strip)
|
876
|
+
#
|
877
|
+
# +:strip+ removes unknown/unsafe tags, but leaves behind the pristine contents:
|
878
|
+
#
|
879
|
+
# unsafe_html = "ohai! <div>div is safe</div> <foo>but foo is <b>not</b></foo>"
|
880
|
+
# Loofah.html5_fragment(unsafe_html).scrub!(:strip)
|
881
|
+
# => "ohai! <div>div is safe</div> but foo is <b>not</b>"
|
882
|
+
#
|
883
|
+
# source://loofah//lib/loofah/scrubbers.rb#114
|
884
|
+
class Loofah::Scrubbers::Strip < ::Loofah::Scrubber
|
885
|
+
# @return [Strip] a new instance of Strip
|
886
|
+
#
|
887
|
+
# source://loofah//lib/loofah/scrubbers.rb#115
|
888
|
+
def initialize; end
|
889
|
+
|
890
|
+
# source://loofah//lib/loofah/scrubbers.rb#119
|
891
|
+
def scrub(node); end
|
892
|
+
end
|
893
|
+
|
894
|
+
# === scrub!(:targetblank)
|
895
|
+
#
|
896
|
+
# +:targetblank+ adds a target="_blank" attribute to all links.
|
897
|
+
# If there is a target already set, replaces it with target="_blank".
|
898
|
+
#
|
899
|
+
# link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
|
900
|
+
# Loofah.html5_fragment(link_farmers_markup).scrub!(:targetblank)
|
901
|
+
# => "ohai! <a href='http://www.myswarmysite.com/' target="_blank">I like your blog post</a>"
|
902
|
+
#
|
903
|
+
# On modern browsers, setting target="_blank" on anchor elements implicitly provides the same
|
904
|
+
# behavior as setting rel="noopener".
|
905
|
+
#
|
906
|
+
# source://loofah//lib/loofah/scrubbers.rb#246
|
907
|
+
class Loofah::Scrubbers::TargetBlank < ::Loofah::Scrubber
|
908
|
+
# @return [TargetBlank] a new instance of TargetBlank
|
909
|
+
#
|
910
|
+
# source://loofah//lib/loofah/scrubbers.rb#247
|
911
|
+
def initialize; end
|
912
|
+
|
913
|
+
# source://loofah//lib/loofah/scrubbers.rb#251
|
914
|
+
def scrub(node); end
|
915
|
+
end
|
916
|
+
|
917
|
+
# === scrub!(:unprintable)
|
918
|
+
#
|
919
|
+
# +:unprintable+ removes unprintable Unicode characters.
|
920
|
+
#
|
921
|
+
# markup = "<p>Some text with an unprintable character at the end\u2028</p>"
|
922
|
+
# Loofah.html5_fragment(markup).scrub!(:unprintable)
|
923
|
+
# => "<p>Some text with an unprintable character at the end</p>"
|
924
|
+
#
|
925
|
+
# You may not be able to see the unprintable character in the above example, but there is a
|
926
|
+
# U+2028 character right before the closing </p> tag. These characters can cause issues if
|
927
|
+
# the content is ever parsed by JavaScript - more information here:
|
928
|
+
#
|
929
|
+
# http://timelessrepo.com/json-isnt-a-javascript-subset
|
930
|
+
#
|
931
|
+
# source://loofah//lib/loofah/scrubbers.rb#338
|
932
|
+
class Loofah::Scrubbers::Unprintable < ::Loofah::Scrubber
|
933
|
+
# @return [Unprintable] a new instance of Unprintable
|
934
|
+
#
|
935
|
+
# source://loofah//lib/loofah/scrubbers.rb#339
|
936
|
+
def initialize; end
|
937
|
+
|
938
|
+
# source://loofah//lib/loofah/scrubbers.rb#343
|
939
|
+
def scrub(node); end
|
940
|
+
end
|
941
|
+
|
942
|
+
# === scrub!(:whitewash)
|
943
|
+
#
|
944
|
+
# +:whitewash+ removes all comments, styling and attributes in
|
945
|
+
# addition to doing markup-fixer-uppery and pruning unsafe tags. I
|
946
|
+
# like to call this "whitewashing", since it's like putting a new
|
947
|
+
# layer of paint on top of the HTML input to make it look nice.
|
948
|
+
#
|
949
|
+
# messy_markup = "ohai! <div id='foo' class='bar' style='margin: 10px'>div with attributes</div>"
|
950
|
+
# Loofah.html5_fragment(messy_markup).scrub!(:whitewash)
|
951
|
+
# => "ohai! <div>div with attributes</div>"
|
952
|
+
#
|
953
|
+
# One use case for this scrubber is to clean up HTML that was
|
954
|
+
# cut-and-pasted from Microsoft Word into a WYSIWYG editor or a
|
955
|
+
# rich text editor. Microsoft's software is famous for injecting
|
956
|
+
# all kinds of cruft into its HTML output. Who needs that crap?
|
957
|
+
# Certainly not me.
|
958
|
+
#
|
959
|
+
# source://loofah//lib/loofah/scrubbers.rb#191
|
960
|
+
class Loofah::Scrubbers::Whitewash < ::Loofah::Scrubber
|
961
|
+
# @return [Whitewash] a new instance of Whitewash
|
962
|
+
#
|
963
|
+
# source://loofah//lib/loofah/scrubbers.rb#192
|
964
|
+
def initialize; end
|
965
|
+
|
966
|
+
# source://loofah//lib/loofah/scrubbers.rb#196
|
967
|
+
def scrub(node); end
|
968
|
+
end
|
969
|
+
|
970
|
+
# Overrides +text+ in Document and DocumentFragment classes, and mixes in +to_text+.
|
971
|
+
#
|
972
|
+
# source://loofah//lib/loofah/concerns.rb#73
|
973
|
+
module Loofah::TextBehavior
|
974
|
+
# Returns a plain-text version of the markup contained by the document, with HTML entities
|
975
|
+
# encoded.
|
976
|
+
#
|
977
|
+
# This method is significantly faster than #to_text, but isn't clever about whitespace around
|
978
|
+
# block elements.
|
979
|
+
#
|
980
|
+
# Loofah.html5_document("<h1>Title</h1><div>Content</div>").text
|
981
|
+
# # => "TitleContent"
|
982
|
+
#
|
983
|
+
# By default, the returned text will have HTML entities escaped. If you want unescaped
|
984
|
+
# entities, and you understand that the result is unsafe to render in a browser, then you can
|
985
|
+
# pass an argument as shown:
|
986
|
+
#
|
987
|
+
# frag = Loofah.html5_fragment("<script>alert('EVIL');</script>")
|
988
|
+
# # ok for browser:
|
989
|
+
# frag.text # => "<script>alert('EVIL');</script>"
|
990
|
+
# # decidedly not ok for browser:
|
991
|
+
# frag.text(:encode_special_chars => false) # => "<script>alert('EVIL');</script>"
|
992
|
+
#
|
993
|
+
# source://loofah//lib/loofah/concerns.rb#94
|
994
|
+
def inner_text(options = T.unsafe(nil)); end
|
995
|
+
|
996
|
+
# Returns a plain-text version of the markup contained by the document, with HTML entities
|
997
|
+
# encoded.
|
998
|
+
#
|
999
|
+
# This method is significantly faster than #to_text, but isn't clever about whitespace around
|
1000
|
+
# block elements.
|
1001
|
+
#
|
1002
|
+
# Loofah.html5_document("<h1>Title</h1><div>Content</div>").text
|
1003
|
+
# # => "TitleContent"
|
1004
|
+
#
|
1005
|
+
# By default, the returned text will have HTML entities escaped. If you want unescaped
|
1006
|
+
# entities, and you understand that the result is unsafe to render in a browser, then you can
|
1007
|
+
# pass an argument as shown:
|
1008
|
+
#
|
1009
|
+
# frag = Loofah.html5_fragment("<script>alert('EVIL');</script>")
|
1010
|
+
# # ok for browser:
|
1011
|
+
# frag.text # => "<script>alert('EVIL');</script>"
|
1012
|
+
# # decidedly not ok for browser:
|
1013
|
+
# frag.text(:encode_special_chars => false) # => "<script>alert('EVIL');</script>"
|
1014
|
+
#
|
1015
|
+
# source://loofah//lib/loofah/concerns.rb#94
|
1016
|
+
def text(options = T.unsafe(nil)); end
|
1017
|
+
|
1018
|
+
# Returns a plain-text version of the markup contained by the document, with HTML entities
|
1019
|
+
# encoded.
|
1020
|
+
#
|
1021
|
+
# This method is significantly faster than #to_text, but isn't clever about whitespace around
|
1022
|
+
# block elements.
|
1023
|
+
#
|
1024
|
+
# Loofah.html5_document("<h1>Title</h1><div>Content</div>").text
|
1025
|
+
# # => "TitleContent"
|
1026
|
+
#
|
1027
|
+
# By default, the returned text will have HTML entities escaped. If you want unescaped
|
1028
|
+
# entities, and you understand that the result is unsafe to render in a browser, then you can
|
1029
|
+
# pass an argument as shown:
|
1030
|
+
#
|
1031
|
+
# frag = Loofah.html5_fragment("<script>alert('EVIL');</script>")
|
1032
|
+
# # ok for browser:
|
1033
|
+
# frag.text # => "<script>alert('EVIL');</script>"
|
1034
|
+
# # decidedly not ok for browser:
|
1035
|
+
# frag.text(:encode_special_chars => false) # => "<script>alert('EVIL');</script>"
|
1036
|
+
#
|
1037
|
+
# source://loofah//lib/loofah/concerns.rb#94
|
1038
|
+
def to_str(options = T.unsafe(nil)); end
|
1039
|
+
|
1040
|
+
# Returns a plain-text version of the markup contained by the fragment, with HTML entities
|
1041
|
+
# encoded.
|
1042
|
+
#
|
1043
|
+
# This method is slower than #text, but is clever about whitespace around block elements and
|
1044
|
+
# line break elements.
|
1045
|
+
#
|
1046
|
+
# Loofah.html5_document("<h1>Title</h1><div>Content<br>Next line</div>").to_text
|
1047
|
+
# # => "\nTitle\n\nContent\nNext line\n"
|
1048
|
+
#
|
1049
|
+
# source://loofah//lib/loofah/concerns.rb#120
|
1050
|
+
def to_text(options = T.unsafe(nil)); end
|
1051
|
+
end
|
1052
|
+
|
1053
|
+
# The version of Loofah you are using
|
1054
|
+
#
|
1055
|
+
# source://loofah//lib/loofah/version.rb#5
|
1056
|
+
Loofah::VERSION = T.let(T.unsafe(nil), String)
|
1057
|
+
|
1058
|
+
# source://loofah//lib/loofah/xml/document.rb#4
|
1059
|
+
module Loofah::XML; end
|
1060
|
+
|
1061
|
+
# Subclass of Nokogiri::XML::Document.
|
1062
|
+
#
|
1063
|
+
# See Loofah::ScrubBehavior and Loofah::DocumentDecorator for additional methods.
|
1064
|
+
#
|
1065
|
+
# source://loofah//lib/loofah/xml/document.rb#10
|
1066
|
+
class Loofah::XML::Document < ::Nokogiri::XML::Document
|
1067
|
+
include ::Loofah::ScrubBehavior::Node
|
1068
|
+
include ::Loofah::DocumentDecorator
|
1069
|
+
end
|
1070
|
+
|
1071
|
+
# Subclass of Nokogiri::XML::DocumentFragment.
|
1072
|
+
#
|
1073
|
+
# See Loofah::ScrubBehavior for additional methods.
|
1074
|
+
#
|
1075
|
+
# source://loofah//lib/loofah/xml/document_fragment.rb#10
|
1076
|
+
class Loofah::XML::DocumentFragment < ::Nokogiri::XML::DocumentFragment
|
1077
|
+
class << self
|
1078
|
+
# source://loofah//lib/loofah/xml/document_fragment.rb#12
|
1079
|
+
def parse(tags); end
|
1080
|
+
end
|
1081
|
+
end
|