phlex-stimulus 0.1.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.
Files changed (147) hide show
  1. checksums.yaml +7 -0
  2. data/.ruby-version +1 -0
  3. data/CHANGELOG.md +16 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +341 -0
  6. data/Rakefile +12 -0
  7. data/lib/generators/phlex/stimulus/controller/USAGE +5 -0
  8. data/lib/generators/phlex/stimulus/controller/controller_generator.rb +49 -0
  9. data/lib/generators/phlex/stimulus/controller/templates/component.rb.erb +30 -0
  10. data/lib/generators/phlex/stimulus/controller/templates/controller.ts.erb +23 -0
  11. data/lib/generators/phlex/stimulus/generator_mixin.rb +21 -0
  12. data/lib/generators/phlex/stimulus/install/USAGE +5 -0
  13. data/lib/generators/phlex/stimulus/install/install_generator.rb +111 -0
  14. data/lib/generators/phlex/stimulus/install/templates/app/components/base.rb.erb +29 -0
  15. data/lib/generators/phlex/stimulus/install/templates/app/components/chain_controller.rb.erb +29 -0
  16. data/lib/generators/phlex/stimulus/install/templates/app/components/classlist_controller.rb.erb +30 -0
  17. data/lib/generators/phlex/stimulus/install/templates/app/components/controller.rb.erb +10 -0
  18. data/lib/generators/phlex/stimulus/install/templates/app/components/controller_chain.rb.erb +32 -0
  19. data/lib/generators/phlex/stimulus/install/templates/app/components/controller_template.rb.erb +24 -0
  20. data/lib/generators/phlex/stimulus/install/templates/app/components/log_controller.rb.erb +33 -0
  21. data/lib/generators/phlex/stimulus/install/templates/app/components/sleep_controller.rb.erb +30 -0
  22. data/lib/generators/phlex/stimulus/install/templates/app/components.rb.erb +7 -0
  23. data/lib/generators/phlex/stimulus/install/templates/app/javascript/application.ts.erb +5 -0
  24. data/lib/generators/phlex/stimulus/install/templates/app/javascript/controllers/application.ts.erb +10 -0
  25. data/lib/generators/phlex/stimulus/install/templates/app/javascript/controllers/chain_controller.ts.erb +32 -0
  26. data/lib/generators/phlex/stimulus/install/templates/app/javascript/controllers/chainable_controller.ts.erb +44 -0
  27. data/lib/generators/phlex/stimulus/install/templates/app/javascript/controllers/classlist_controller.ts.erb +30 -0
  28. data/lib/generators/phlex/stimulus/install/templates/app/javascript/controllers/index.ts.erb +4 -0
  29. data/lib/generators/phlex/stimulus/install/templates/app/javascript/controllers/log_controller.ts.erb +25 -0
  30. data/lib/generators/phlex/stimulus/install/templates/app/javascript/controllers/sleep_controller.ts.erb +19 -0
  31. data/lib/generators/phlex/stimulus/install/templates/app/javascript/controllers/typed_controller.ts.erb +53 -0
  32. data/lib/generators/phlex/stimulus/install/templates/app/javascript/utils/misc.ts.erb +37 -0
  33. data/lib/generators/phlex/stimulus/install/templates/app/javascript/utils/template.ts.erb +11 -0
  34. data/lib/phlex/stimulus/components/base.rb +81 -0
  35. data/lib/phlex/stimulus/components/controller.rb +170 -0
  36. data/lib/phlex/stimulus/components.rb +9 -0
  37. data/lib/phlex/stimulus/version.rb +8 -0
  38. data/lib/phlex/stimulus.rb +15 -0
  39. data/sorbet/config +7 -0
  40. data/sorbet/rbi/annotations/.gitattributes +1 -0
  41. data/sorbet/rbi/annotations/actionmailer.rbi +15 -0
  42. data/sorbet/rbi/annotations/actionpack.rbi +430 -0
  43. data/sorbet/rbi/annotations/actionview.rbi +75 -0
  44. data/sorbet/rbi/annotations/activejob.rbi +50 -0
  45. data/sorbet/rbi/annotations/activemodel.rbi +119 -0
  46. data/sorbet/rbi/annotations/activerecord.rbi +172 -0
  47. data/sorbet/rbi/annotations/activesupport.rbi +561 -0
  48. data/sorbet/rbi/annotations/globalid.rbi +30 -0
  49. data/sorbet/rbi/annotations/minitest.rbi +116 -0
  50. data/sorbet/rbi/annotations/railties.rbi +104 -0
  51. data/sorbet/rbi/annotations/rainbow.rbi +269 -0
  52. data/sorbet/rbi/dsl/.gitattributes +1 -0
  53. data/sorbet/rbi/dsl/active_support/callbacks.rbi +21 -0
  54. data/sorbet/rbi/gems/.gitattributes +1 -0
  55. data/sorbet/rbi/gems/action_text-trix@2.1.19.rbi +9 -0
  56. data/sorbet/rbi/gems/actioncable@8.1.3.rbi +9 -0
  57. data/sorbet/rbi/gems/actionmailbox@8.1.3.rbi +9 -0
  58. data/sorbet/rbi/gems/actionmailer@8.1.3.rbi +9 -0
  59. data/sorbet/rbi/gems/actionpack@8.1.3.rbi +20478 -0
  60. data/sorbet/rbi/gems/actiontext@8.1.3.rbi +9 -0
  61. data/sorbet/rbi/gems/actionview@8.1.3.rbi +14722 -0
  62. data/sorbet/rbi/gems/activejob@8.1.3.rbi +9 -0
  63. data/sorbet/rbi/gems/activemodel@8.1.3.rbi +9 -0
  64. data/sorbet/rbi/gems/activerecord@8.1.3.rbi +9 -0
  65. data/sorbet/rbi/gems/activestorage@8.1.3.rbi +9 -0
  66. data/sorbet/rbi/gems/activesupport@8.1.3.rbi +20153 -0
  67. data/sorbet/rbi/gems/ast@2.4.3.rbi +550 -0
  68. data/sorbet/rbi/gems/base64@0.3.0.rbi +545 -0
  69. data/sorbet/rbi/gems/benchmark@0.5.0.rbi +621 -0
  70. data/sorbet/rbi/gems/booleans@0.1.3.rbi +31 -0
  71. data/sorbet/rbi/gems/builder@3.3.0.rbi +9 -0
  72. data/sorbet/rbi/gems/byebug@12.0.0.rbi +49 -0
  73. data/sorbet/rbi/gems/concurrent-ruby@1.3.8.rbi +10656 -0
  74. data/sorbet/rbi/gems/connection_pool@3.0.2.rbi +9 -0
  75. data/sorbet/rbi/gems/crass@1.0.7.rbi +648 -0
  76. data/sorbet/rbi/gems/date@3.5.1.rbi +391 -0
  77. data/sorbet/rbi/gems/drb@2.2.3.rbi +9 -0
  78. data/sorbet/rbi/gems/erb@6.0.6.rbi +1600 -0
  79. data/sorbet/rbi/gems/erubi@1.13.1.rbi +155 -0
  80. data/sorbet/rbi/gems/globalid@1.4.0.rbi +9 -0
  81. data/sorbet/rbi/gems/i18n@1.15.2.rbi +2285 -0
  82. data/sorbet/rbi/gems/io-console@0.8.2.rbi +9 -0
  83. data/sorbet/rbi/gems/json@2.21.1.rbi +2289 -0
  84. data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +189 -0
  85. data/sorbet/rbi/gems/logger@1.7.0.rbi +896 -0
  86. data/sorbet/rbi/gems/loofah@2.25.2.rbi +1134 -0
  87. data/sorbet/rbi/gems/mail@2.9.1.rbi +9 -0
  88. data/sorbet/rbi/gems/marcel@1.2.1.rbi +9 -0
  89. data/sorbet/rbi/gems/mini_mime@1.1.5.rbi +9 -0
  90. data/sorbet/rbi/gems/minitest@6.0.6.rbi +1482 -0
  91. data/sorbet/rbi/gems/net-imap@0.6.4.1.rbi +9 -0
  92. data/sorbet/rbi/gems/net-pop@0.1.2.rbi +9 -0
  93. data/sorbet/rbi/gems/net-protocol@0.2.2.rbi +244 -0
  94. data/sorbet/rbi/gems/net-smtp@0.5.1.rbi +9 -0
  95. data/sorbet/rbi/gems/netrc@0.11.0.rbi +147 -0
  96. data/sorbet/rbi/gems/nio4r@2.7.5.rbi +9 -0
  97. data/sorbet/rbi/gems/nokogiri@1.19.4.rbi +8168 -0
  98. data/sorbet/rbi/gems/parallel@1.28.0.rbi +270 -0
  99. data/sorbet/rbi/gems/phlex-rails@2.4.0.rbi +1945 -0
  100. data/sorbet/rbi/gems/phlex@2.4.1.rbi +1413 -0
  101. data/sorbet/rbi/gems/pp@0.6.4.rbi +387 -0
  102. data/sorbet/rbi/gems/prettyprint@0.2.0.rbi +455 -0
  103. data/sorbet/rbi/gems/prism@1.9.0.rbi +42226 -0
  104. data/sorbet/rbi/gems/racc@1.8.1.rbi +165 -0
  105. data/sorbet/rbi/gems/rack-session@2.1.2.rbi +756 -0
  106. data/sorbet/rbi/gems/rack-test@2.2.0.rbi +681 -0
  107. data/sorbet/rbi/gems/rack@3.2.6.rbi +4653 -0
  108. data/sorbet/rbi/gems/rackup@2.3.1.rbi +9 -0
  109. data/sorbet/rbi/gems/rails-dom-testing@2.3.0.rbi +517 -0
  110. data/sorbet/rbi/gems/rails-html-sanitizer@1.7.1.rbi +620 -0
  111. data/sorbet/rbi/gems/rails@8.1.3.rbi +9 -0
  112. data/sorbet/rbi/gems/railties@8.1.3.rbi +3507 -0
  113. data/sorbet/rbi/gems/rainbow@3.1.1.rbi +362 -0
  114. data/sorbet/rbi/gems/rake@13.4.2.rbi +3130 -0
  115. data/sorbet/rbi/gems/rbi@0.4.0.rbi +5706 -0
  116. data/sorbet/rbi/gems/rbs@4.0.3.rbi +6908 -0
  117. data/sorbet/rbi/gems/refract@1.1.0.rbi +9 -0
  118. data/sorbet/rbi/gems/reline@0.6.3.rbi +2446 -0
  119. data/sorbet/rbi/gems/require-hooks@0.4.0.rbi +152 -0
  120. data/sorbet/rbi/gems/rexml@3.4.4.rbi +4905 -0
  121. data/sorbet/rbi/gems/rubocop-espago@1.3.0.rbi +9 -0
  122. data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +988 -0
  123. data/sorbet/rbi/gems/rubydex@0.2.9.rbi +841 -0
  124. data/sorbet/rbi/gems/securerandom@0.4.1.rbi +75 -0
  125. data/sorbet/rbi/gems/shoulda-context@2.0.0.rbi +544 -0
  126. data/sorbet/rbi/gems/spoom@1.8.4.rbi +6738 -0
  127. data/sorbet/rbi/gems/tapioca@0.19.2.rbi +3599 -0
  128. data/sorbet/rbi/gems/thor@1.5.0.rbi +3870 -0
  129. data/sorbet/rbi/gems/timeout@0.6.1.rbi +200 -0
  130. data/sorbet/rbi/gems/tsort@0.2.0.rbi +389 -0
  131. data/sorbet/rbi/gems/tzinfo@2.0.6.rbi +5474 -0
  132. data/sorbet/rbi/gems/unicode-display_width@3.2.0.rbi +130 -0
  133. data/sorbet/rbi/gems/unicode-emoji@4.2.0.rbi +332 -0
  134. data/sorbet/rbi/gems/uri@1.1.1.rbi +2402 -0
  135. data/sorbet/rbi/gems/useragent@0.16.11.rbi +9 -0
  136. data/sorbet/rbi/gems/websocket-driver@0.8.2.rbi +9 -0
  137. data/sorbet/rbi/gems/websocket-extensions@0.1.5.rbi +9 -0
  138. data/sorbet/rbi/gems/zeitwerk@2.8.2.rbi +9 -0
  139. data/sorbet/rbi/shims/gems/parser.rbi +12 -0
  140. data/sorbet/rbi/shims/gems/rails.rbi +55 -0
  141. data/sorbet/rbi/shims/gems/refract.rbi +13 -0
  142. data/sorbet/rbi/shims/gems/shoulda-context.rbi +16 -0
  143. data/sorbet/tapioca/compilers/phlex_controller.rb +80 -0
  144. data/sorbet/tapioca/config.yml +26 -0
  145. data/sorbet/tapioca/extensions/load_gem.rb +1 -0
  146. data/sorbet/tapioca/require.rb +4 -0
  147. metadata +266 -0
@@ -0,0 +1,1134 @@
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
+ # pkg:gem/loofah#lib/loofah.rb:5
36
+ module Loofah
37
+ class << self
38
+ # pkg:gem/loofah#lib/loofah.rb:139
39
+ def document(*args, &block); end
40
+
41
+ # pkg:gem/loofah#lib/loofah.rb:140
42
+ def fragment(*args, &block); end
43
+
44
+ # Shortcut for Loofah::HTML4::Document.parse(*args, &block)
45
+ #
46
+ # This method accepts the same parameters as Nokogiri::HTML4::Document.parse
47
+ #
48
+ # pkg:gem/loofah#lib/loofah.rb:76
49
+ def html4_document(*args, &block); end
50
+
51
+ # Shortcut for Loofah::HTML4::DocumentFragment.parse(*args, &block)
52
+ #
53
+ # This method accepts the same parameters as Nokogiri::HTML4::DocumentFragment.parse
54
+ #
55
+ # pkg:gem/loofah#lib/loofah.rb:83
56
+ def html4_fragment(*args, &block); end
57
+
58
+ # Shortcut for Loofah::HTML5::Document.parse(*args, &block)
59
+ #
60
+ # This method accepts the same parameters as Nokogiri::HTML5::Document.parse
61
+ #
62
+ # pkg:gem/loofah#lib/loofah.rb:101
63
+ def html5_document(*args, &block); end
64
+
65
+ # Shortcut for Loofah::HTML5::DocumentFragment.parse(*args, &block)
66
+ #
67
+ # This method accepts the same parameters as Nokogiri::HTML5::DocumentFragment.parse
68
+ #
69
+ # pkg:gem/loofah#lib/loofah.rb:108
70
+ def html5_fragment(*args, &block); end
71
+
72
+ # pkg:gem/loofah#lib/loofah.rb:7
73
+ def html5_support?; end
74
+
75
+ # A helper to remove extraneous whitespace from text-ified HTML
76
+ #
77
+ # pkg:gem/loofah#lib/loofah.rb:169
78
+ def remove_extraneous_whitespace(string); end
79
+
80
+ # pkg:gem/loofah#lib/loofah.rb:141
81
+ def scrub_document(string_or_io, method); end
82
+
83
+ # pkg:gem/loofah#lib/loofah.rb:142
84
+ def scrub_fragment(string_or_io, method); end
85
+
86
+ # Shortcut for Loofah::HTML4::Document.parse(string_or_io).scrub!(method)
87
+ #
88
+ # pkg:gem/loofah#lib/loofah.rb:88
89
+ def scrub_html4_document(string_or_io, method); end
90
+
91
+ # Shortcut for Loofah::HTML4::DocumentFragment.parse(string_or_io).scrub!(method)
92
+ #
93
+ # pkg:gem/loofah#lib/loofah.rb:93
94
+ def scrub_html4_fragment(string_or_io, method); end
95
+
96
+ # Shortcut for Loofah::HTML5::Document.parse(string_or_io).scrub!(method)
97
+ #
98
+ # pkg:gem/loofah#lib/loofah.rb:113
99
+ def scrub_html5_document(string_or_io, method); end
100
+
101
+ # Shortcut for Loofah::HTML5::DocumentFragment.parse(string_or_io).scrub!(method)
102
+ #
103
+ # pkg:gem/loofah#lib/loofah.rb:118
104
+ def scrub_html5_fragment(string_or_io, method); end
105
+
106
+ # Shortcut for Loofah.xml_document(string_or_io).scrub!(method)
107
+ #
108
+ # pkg:gem/loofah#lib/loofah.rb:164
109
+ def scrub_xml_document(string_or_io, method); end
110
+
111
+ # Shortcut for Loofah.xml_fragment(string_or_io).scrub!(method)
112
+ #
113
+ # pkg:gem/loofah#lib/loofah.rb:159
114
+ def scrub_xml_fragment(string_or_io, method); end
115
+
116
+ # Shortcut for Loofah::XML::Document.parse(*args, &block)
117
+ #
118
+ # This method accepts the same parameters as Nokogiri::XML::Document.parse
119
+ #
120
+ # pkg:gem/loofah#lib/loofah.rb:147
121
+ def xml_document(*args, &block); end
122
+
123
+ # Shortcut for Loofah::XML::DocumentFragment.parse(*args, &block)
124
+ #
125
+ # This method accepts the same parameters as Nokogiri::XML::DocumentFragment.parse
126
+ #
127
+ # pkg:gem/loofah#lib/loofah.rb:154
128
+ def xml_fragment(*args, &block); end
129
+ end
130
+ end
131
+
132
+ # pkg:gem/loofah#lib/loofah/concerns.rb:125
133
+ module Loofah::DocumentDecorator
134
+ # pkg:gem/loofah#lib/loofah/concerns.rb:126
135
+ def initialize(*args, &block); end
136
+ end
137
+
138
+ # pkg:gem/loofah#lib/loofah/elements.rb:6
139
+ module Loofah::Elements; end
140
+
141
+ # pkg:gem/loofah#lib/loofah/elements.rb:93
142
+ Loofah::Elements::BLOCK_LEVEL = T.let(T.unsafe(nil), Set)
143
+
144
+ # Elements that aren't block but should generate a newline in #to_text
145
+ #
146
+ # pkg:gem/loofah#lib/loofah/elements.rb:90
147
+ Loofah::Elements::INLINE_LINE_BREAK = T.let(T.unsafe(nil), Set)
148
+
149
+ # pkg:gem/loofah#lib/loofah/elements.rb:94
150
+ Loofah::Elements::LINEBREAKERS = T.let(T.unsafe(nil), Set)
151
+
152
+ # The following elements may also be considered block-level
153
+ # elements since they may contain block-level elements
154
+ #
155
+ # pkg:gem/loofah#lib/loofah/elements.rb:76
156
+ Loofah::Elements::LOOSE_BLOCK_LEVEL = T.let(T.unsafe(nil), Set)
157
+
158
+ # pkg:gem/loofah#lib/loofah/elements.rb:92
159
+ Loofah::Elements::STRICT_BLOCK_LEVEL = T.let(T.unsafe(nil), Set)
160
+
161
+ # pkg:gem/loofah#lib/loofah/elements.rb:7
162
+ Loofah::Elements::STRICT_BLOCK_LEVEL_HTML4 = T.let(T.unsafe(nil), Set)
163
+
164
+ # https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
165
+ #
166
+ # pkg:gem/loofah#lib/loofah/elements.rb:35
167
+ Loofah::Elements::STRICT_BLOCK_LEVEL_HTML5 = T.let(T.unsafe(nil), Set)
168
+
169
+ # Alias for Loofah::HTML4
170
+ #
171
+ # pkg:gem/loofah#lib/loofah.rb:70
172
+ Loofah::HTML = Loofah::HTML4
173
+
174
+ # pkg:gem/loofah#lib/loofah/html4/document.rb:4
175
+ module Loofah::HTML4; end
176
+
177
+ # Subclass of Nokogiri::HTML4::Document.
178
+ #
179
+ # See Loofah::ScrubBehavior and Loofah::TextBehavior for additional methods.
180
+ #
181
+ # pkg:gem/loofah#lib/loofah/html4/document.rb:10
182
+ class Loofah::HTML4::Document < ::Nokogiri::HTML4::Document
183
+ include ::Loofah::ScrubBehavior::Node
184
+ include ::Loofah::DocumentDecorator
185
+ include ::Loofah::TextBehavior
186
+ include ::Loofah::HtmlDocumentBehavior
187
+ extend ::Loofah::HtmlDocumentBehavior::ClassMethods
188
+ end
189
+
190
+ # Subclass of Nokogiri::HTML4::DocumentFragment.
191
+ #
192
+ # See Loofah::ScrubBehavior and Loofah::TextBehavior for additional methods.
193
+ #
194
+ # pkg:gem/loofah#lib/loofah/html4/document_fragment.rb:10
195
+ class Loofah::HTML4::DocumentFragment < ::Nokogiri::HTML4::DocumentFragment
196
+ include ::Loofah::TextBehavior
197
+ include ::Loofah::HtmlFragmentBehavior
198
+ extend ::Loofah::HtmlFragmentBehavior::ClassMethods
199
+ end
200
+
201
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:6
202
+ module Loofah::HTML5; end
203
+
204
+ # Subclass of Nokogiri::HTML5::Document.
205
+ #
206
+ # See Loofah::ScrubBehavior and Loofah::TextBehavior for additional methods.
207
+ #
208
+ # pkg:gem/loofah#lib/loofah/html5/document.rb:10
209
+ class Loofah::HTML5::Document < ::Nokogiri::HTML5::Document
210
+ include ::Loofah::ScrubBehavior::Node
211
+ include ::Loofah::DocumentDecorator
212
+ include ::Loofah::TextBehavior
213
+ include ::Loofah::HtmlDocumentBehavior
214
+ extend ::Loofah::HtmlDocumentBehavior::ClassMethods
215
+ end
216
+
217
+ # Subclass of Nokogiri::HTML5::DocumentFragment.
218
+ #
219
+ # See Loofah::ScrubBehavior and Loofah::TextBehavior for additional methods.
220
+ #
221
+ # pkg:gem/loofah#lib/loofah/html5/document_fragment.rb:10
222
+ class Loofah::HTML5::DocumentFragment < ::Nokogiri::HTML5::DocumentFragment
223
+ include ::Loofah::TextBehavior
224
+ include ::Loofah::HtmlFragmentBehavior
225
+ extend ::Loofah::HtmlFragmentBehavior::ClassMethods
226
+ end
227
+
228
+ # HTML safelist lifted from HTML5lib sanitizer code:
229
+ #
230
+ # http://code.google.com/p/html5lib/
231
+ #
232
+ # <html5_license>
233
+ #
234
+ # Copyright (c) 2006-2008 The Authors
235
+ #
236
+ # Contributors:
237
+ # James Graham - jg307@cam.ac.uk
238
+ # Anne van Kesteren - annevankesteren@gmail.com
239
+ # Lachlan Hunt - lachlan.hunt@lachy.id.au
240
+ # Matt McDonald - kanashii@kanashii.ca
241
+ # Sam Ruby - rubys@intertwingly.net
242
+ # Ian Hickson (Google) - ian@hixie.ch
243
+ # Thomas Broyer - t.broyer@ltgt.net
244
+ # Jacques Distler - distler@golem.ph.utexas.edu
245
+ # Henri Sivonen - hsivonen@iki.fi
246
+ # The Mozilla Foundation (contributions from Henri Sivonen since 2008)
247
+ #
248
+ # Permission is hereby granted, free of charge, to any person
249
+ # obtaining a copy of this software and associated documentation
250
+ # files (the "Software"), to deal in the Software without
251
+ # restriction, including without limitation the rights to use, copy,
252
+ # modify, merge, publish, distribute, sublicense, and/or sell copies
253
+ # of the Software, and to permit persons to whom the Software is
254
+ # furnished to do so, subject to the following conditions:
255
+ #
256
+ # The above copyright notice and this permission notice shall be
257
+ # included in all copies or substantial portions of the Software.
258
+ #
259
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
260
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
261
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
262
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
263
+ # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
264
+ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
265
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
266
+ # DEALINGS IN THE SOFTWARE.
267
+ #
268
+ # </html5_license>
269
+ #
270
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:49
271
+ module Loofah::HTML5::SafeList; end
272
+
273
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:232
274
+ Loofah::HTML5::SafeList::ACCEPTABLE_ATTRIBUTES = T.let(T.unsafe(nil), Set)
275
+
276
+ # https://www.w3.org/TR/css-color-3/#html4
277
+ #
278
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:743
279
+ Loofah::HTML5::SafeList::ACCEPTABLE_CSS_COLORS = T.let(T.unsafe(nil), Set)
280
+
281
+ # https://www.w3.org/TR/css-color-3/#svg-color
282
+ #
283
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:763
284
+ Loofah::HTML5::SafeList::ACCEPTABLE_CSS_EXTENDED_COLORS = T.let(T.unsafe(nil), Set)
285
+
286
+ # see https://www.quackit.com/css/functions/
287
+ # omit `url` and `image` from that list
288
+ #
289
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:915
290
+ Loofah::HTML5::SafeList::ACCEPTABLE_CSS_FUNCTIONS = T.let(T.unsafe(nil), Set)
291
+
292
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:704
293
+ Loofah::HTML5::SafeList::ACCEPTABLE_CSS_KEYWORDS = T.let(T.unsafe(nil), Set)
294
+
295
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:631
296
+ Loofah::HTML5::SafeList::ACCEPTABLE_CSS_PROPERTIES = T.let(T.unsafe(nil), Set)
297
+
298
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:50
299
+ Loofah::HTML5::SafeList::ACCEPTABLE_ELEMENTS = T.let(T.unsafe(nil), Set)
300
+
301
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:988
302
+ Loofah::HTML5::SafeList::ACCEPTABLE_PROTOCOLS = T.let(T.unsafe(nil), Set)
303
+
304
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:975
305
+ Loofah::HTML5::SafeList::ACCEPTABLE_SVG_PROPERTIES = T.let(T.unsafe(nil), Set)
306
+
307
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:1018
308
+ Loofah::HTML5::SafeList::ACCEPTABLE_URI_DATA_MEDIATYPES = T.let(T.unsafe(nil), Set)
309
+
310
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:1028
311
+ Loofah::HTML5::SafeList::ALLOWED_ATTRIBUTES = T.let(T.unsafe(nil), Set)
312
+
313
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:1031
314
+ Loofah::HTML5::SafeList::ALLOWED_CSS_FUNCTIONS = T.let(T.unsafe(nil), Set)
315
+
316
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:1030
317
+ Loofah::HTML5::SafeList::ALLOWED_CSS_KEYWORDS = T.let(T.unsafe(nil), Set)
318
+
319
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:1029
320
+ Loofah::HTML5::SafeList::ALLOWED_CSS_PROPERTIES = T.let(T.unsafe(nil), Set)
321
+
322
+ # subclasses may define their own versions of these constants
323
+ #
324
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:1027
325
+ Loofah::HTML5::SafeList::ALLOWED_ELEMENTS = T.let(T.unsafe(nil), Set)
326
+
327
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:1052
328
+ Loofah::HTML5::SafeList::ALLOWED_ELEMENTS_WITH_LIBXML2 = T.let(T.unsafe(nil), Set)
329
+
330
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:1033
331
+ Loofah::HTML5::SafeList::ALLOWED_PROTOCOLS = T.let(T.unsafe(nil), Set)
332
+
333
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:1032
334
+ Loofah::HTML5::SafeList::ALLOWED_SVG_PROPERTIES = T.let(T.unsafe(nil), Set)
335
+
336
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:1034
337
+ Loofah::HTML5::SafeList::ALLOWED_URI_DATA_MEDIATYPES = T.let(T.unsafe(nil), Set)
338
+
339
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:526
340
+ Loofah::HTML5::SafeList::ARIA_ATTRIBUTES = T.let(T.unsafe(nil), Set)
341
+
342
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:582
343
+ Loofah::HTML5::SafeList::ATTR_VAL_IS_URI = T.let(T.unsafe(nil), Set)
344
+
345
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:315
346
+ Loofah::HTML5::SafeList::MATHML_ATTRIBUTES = T.let(T.unsafe(nil), Set)
347
+
348
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:147
349
+ Loofah::HTML5::SafeList::MATHML_ELEMENTS = T.let(T.unsafe(nil), Set)
350
+
351
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:986
352
+ Loofah::HTML5::SafeList::PROTOCOL_SEPARATOR = T.let(T.unsafe(nil), Regexp)
353
+
354
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:968
355
+ Loofah::HTML5::SafeList::SHORTHAND_CSS_PROPERTIES = T.let(T.unsafe(nil), Set)
356
+
357
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:613
358
+ Loofah::HTML5::SafeList::SVG_ALLOW_LOCAL_HREF = T.let(T.unsafe(nil), Set)
359
+
360
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:367
361
+ Loofah::HTML5::SafeList::SVG_ATTRIBUTES = T.let(T.unsafe(nil), Set)
362
+
363
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:594
364
+ Loofah::HTML5::SafeList::SVG_ATTR_VAL_ALLOWS_REF = T.let(T.unsafe(nil), Set)
365
+
366
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:183
367
+ Loofah::HTML5::SafeList::SVG_ELEMENTS = T.let(T.unsafe(nil), Set)
368
+
369
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:608
370
+ Loofah::HTML5::SafeList::SVG_HREF_ATTRIBUTES = T.let(T.unsafe(nil), Set)
371
+
372
+ # additional tags we should consider safe since we have libxml2 fixing up our documents.
373
+ #
374
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:1047
375
+ Loofah::HTML5::SafeList::TAGS_SAFE_WITH_LIBXML2 = T.let(T.unsafe(nil), Set)
376
+
377
+ # TODO: remove VOID_ELEMENTS in a future major release
378
+ # and put it in the tests (it is used only for testing, not for functional behavior)
379
+ #
380
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:1038
381
+ Loofah::HTML5::SafeList::VOID_ELEMENTS = T.let(T.unsafe(nil), Set)
382
+
383
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:9
384
+ module Loofah::HTML5::Scrub
385
+ class << self
386
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:56
387
+ def allowed_element?(element_name); end
388
+
389
+ # Returns true if the given URI string is safe, false otherwise. This method can be used to
390
+ # validate URI attribute values without requiring a Nokogiri DOM node.
391
+ #
392
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:182
393
+ def allowed_uri?(uri_string); end
394
+
395
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:266
396
+ def cdata_escape(node); end
397
+
398
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:261
399
+ def cdata_needs_escaping?(node); end
400
+
401
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:206
402
+ def decode_numeric_character_references(string); end
403
+
404
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:281
405
+ def escape_tags(string); end
406
+
407
+ # libxml2 >= 2.9.2 fails to escape comments within some attributes.
408
+ #
409
+ # see comments about CVE-2018-8048 within the tests for more information
410
+ #
411
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:240
412
+ def force_correct_attribute_escaping!(node); end
413
+
414
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:161
415
+ def scrub_attribute_that_allows_local_ref(attr_node); end
416
+
417
+ # alternative implementation of the html5lib attribute scrubbing algorithm
418
+ #
419
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:61
420
+ def scrub_attributes(node); end
421
+
422
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:110
423
+ def scrub_css(style); end
424
+
425
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:105
426
+ def scrub_css_attribute(node); end
427
+
428
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:226
429
+ def scrub_uri_attribute(attr_node); end
430
+
431
+ private
432
+
433
+ # Returns the mediatype of a data: URI per RFC 2397, or nil when the
434
+ # required comma is absent. allowed_uri? entity-decodes, downcases, and
435
+ # strips control characters before calling this. An omitted or malformed
436
+ # mediatype resolves to "text/plain", matching the WHATWG data: URL processor.
437
+ #
438
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:307
439
+ def data_uri_mediatype(uri_string); end
440
+ end
441
+ end
442
+
443
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:10
444
+ Loofah::HTML5::Scrub::CONTROL_CHARACTERS = T.let(T.unsafe(nil), Regexp)
445
+
446
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:12
447
+ Loofah::HTML5::Scrub::CRASS_SEMICOLON = T.let(T.unsafe(nil), Hash)
448
+
449
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:13
450
+ Loofah::HTML5::Scrub::CSS_IMPORTANT = T.let(T.unsafe(nil), String)
451
+
452
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:11
453
+ Loofah::HTML5::Scrub::CSS_KEYWORDISH = T.let(T.unsafe(nil), Regexp)
454
+
455
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:15
456
+ Loofah::HTML5::Scrub::CSS_PROPERTY_STRING_WITHOUT_EMBEDDED_QUOTES = T.let(T.unsafe(nil), Regexp)
457
+
458
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:14
459
+ Loofah::HTML5::Scrub::CSS_WHITESPACE = T.let(T.unsafe(nil), String)
460
+
461
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:16
462
+ Loofah::HTML5::Scrub::DATA_ATTRIBUTE_NAME = T.let(T.unsafe(nil), Regexp)
463
+
464
+ # Matches a valid MIME type "essence" (type "/" subtype, no parameters), used to
465
+ # decide whether a data: URI mediatype is well-formed; a non-match is not a valid
466
+ # MIME type, which the data: URL processor treats as text/plain. Specs:
467
+ #
468
+ # https://mimesniff.spec.whatwg.org/#valid-mime-type
469
+ # https://mimesniff.spec.whatwg.org/#mime-type-essence
470
+ # https://mimesniff.spec.whatwg.org/#http-token-code-point
471
+ #
472
+ # The character class below is the HTTP token set (tchar) from RFC 9110 section
473
+ # 5.6.2, https://www.rfc-editor.org/rfc/rfc9110#name-tokens :
474
+ #
475
+ # tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / "^"
476
+ # / "_" / "`" / "|" / "~" / DIGIT / ALPHA
477
+ #
478
+ # ALPHA is written a-z, not a-zA-Z, because allowed_uri? downcases the input first.
479
+ #
480
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:43
481
+ Loofah::HTML5::Scrub::DATA_URI_MEDIATYPE = T.let(T.unsafe(nil), Regexp)
482
+
483
+ # Decimal (`&#58`) or hexadecimal (`&#x3a`) form, with or without the trailing semicolon that
484
+ # CGI.unescapeHTML requires but browsers do not.
485
+ #
486
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:20
487
+ Loofah::HTML5::Scrub::NUMERIC_CHARACTER_REFERENCE = T.let(T.unsafe(nil), Regexp)
488
+
489
+ # A scheme (RFC 3986) followed by a protocol separator. The separator must recognize the same
490
+ # encoded-colon forms as PROTOCOL_SEPARATOR, otherwise a scheme split by an encoded colon (for
491
+ # example "javascript&#58alert(1)") would not be recognized as having a scheme and would skip
492
+ # protocol validation.
493
+ #
494
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:26
495
+ Loofah::HTML5::Scrub::URI_PROTOCOL_REGEX = T.let(T.unsafe(nil), Regexp)
496
+
497
+ # HTML5 named character references for whitespace that browsers strip from
498
+ # URIs. CGI.unescapeHTML does not decode these, so they are handled explicitly.
499
+ #
500
+ # pkg:gem/loofah#lib/loofah/html5/scrub.rb:53
501
+ Loofah::HTML5::Scrub::WHITESPACE_CHARACTER_REFERENCES = T.let(T.unsafe(nil), Regexp)
502
+
503
+ # pkg:gem/loofah#lib/loofah/html5/safelist.rb:1055
504
+ Loofah::HTML5::WhiteList = Loofah::HTML5::SafeList
505
+
506
+ # pkg:gem/loofah#lib/loofah/concerns.rb:133
507
+ module Loofah::HtmlDocumentBehavior
508
+ mixes_in_class_methods ::Loofah::HtmlDocumentBehavior::ClassMethods
509
+
510
+ # pkg:gem/loofah#lib/loofah/concerns.rb:164
511
+ def serialize_root; end
512
+
513
+ class << self
514
+ # pkg:gem/loofah#lib/loofah/concerns.rb:159
515
+ def included(base); end
516
+ end
517
+ end
518
+
519
+ # pkg:gem/loofah#lib/loofah/concerns.rb:134
520
+ module Loofah::HtmlDocumentBehavior::ClassMethods
521
+ # pkg:gem/loofah#lib/loofah/concerns.rb:135
522
+ def parse(*args, &block); end
523
+
524
+ private
525
+
526
+ # remove comments that exist outside of the HTML element.
527
+ #
528
+ # these comments are allowed by the HTML spec:
529
+ #
530
+ # https://www.w3.org/TR/html401/struct/global.html#h-7.1
531
+ #
532
+ # but are not scrubbed by Loofah because these nodes don't meet
533
+ # the contract that scrubbers expect of a node (e.g., it can be
534
+ # replaced, sibling and children nodes can be created).
535
+ #
536
+ # pkg:gem/loofah#lib/loofah/concerns.rb:150
537
+ def remove_comments_before_html_element(doc); end
538
+ end
539
+
540
+ # pkg:gem/loofah#lib/loofah/concerns.rb:169
541
+ module Loofah::HtmlFragmentBehavior
542
+ mixes_in_class_methods ::Loofah::HtmlFragmentBehavior::ClassMethods
543
+
544
+ # pkg:gem/loofah#lib/loofah/concerns.rb:201
545
+ def serialize; end
546
+
547
+ # pkg:gem/loofah#lib/loofah/concerns.rb:203
548
+ def serialize_root; end
549
+
550
+ # pkg:gem/loofah#lib/loofah/concerns.rb:197
551
+ def to_s; end
552
+
553
+ class << self
554
+ # pkg:gem/loofah#lib/loofah/concerns.rb:192
555
+ def included(base); end
556
+ end
557
+ end
558
+
559
+ # pkg:gem/loofah#lib/loofah/concerns.rb:170
560
+ module Loofah::HtmlFragmentBehavior::ClassMethods
561
+ # pkg:gem/loofah#lib/loofah/concerns.rb:180
562
+ def document_klass; end
563
+
564
+ # pkg:gem/loofah#lib/loofah/concerns.rb:171
565
+ def parse(tags, encoding = T.unsafe(nil)); end
566
+ end
567
+
568
+ # constants related to working around unhelpful libxml2 behavior
569
+ #
570
+ # ಠ_ಠ
571
+ #
572
+ # pkg:gem/loofah#lib/loofah/html5/libxml2_workarounds.rb:12
573
+ module Loofah::LibxmlWorkarounds; end
574
+
575
+ # these attributes and qualifying parent tags are determined by the code at:
576
+ #
577
+ # https://git.gnome.org/browse/libxml2/tree/HTMLtree.c?h=v2.9.2#n714
578
+ #
579
+ # see comments about CVE-2018-8048 within the tests for more information
580
+ #
581
+ # pkg:gem/loofah#lib/loofah/html5/libxml2_workarounds.rb:20
582
+ Loofah::LibxmlWorkarounds::BROKEN_ESCAPING_ATTRIBUTES = T.let(T.unsafe(nil), Set)
583
+
584
+ # pkg:gem/loofah#lib/loofah/html5/libxml2_workarounds.rb:26
585
+ Loofah::LibxmlWorkarounds::BROKEN_ESCAPING_ATTRIBUTES_QUALIFYING_TAG = T.let(T.unsafe(nil), Hash)
586
+
587
+ # pkg:gem/loofah#lib/loofah/metahelpers.rb:4
588
+ module Loofah::MetaHelpers
589
+ class << self
590
+ # pkg:gem/loofah#lib/loofah/metahelpers.rb:6
591
+ def add_downcased_set_members_to_all_set_constants(mojule); end
592
+ end
593
+ end
594
+
595
+ # Mixes +scrub!+ into Document, DocumentFragment, Node and NodeSet.
596
+ #
597
+ # Traverse the document or fragment, invoking the +scrubber+ on each node.
598
+ #
599
+ # +scrubber+ must either be one of the symbols representing the built-in scrubbers (see
600
+ # Scrubbers), or a Scrubber instance.
601
+ #
602
+ # span2div = Loofah::Scrubber.new do |node|
603
+ # node.name = "div" if node.name == "span"
604
+ # end
605
+ # Loofah.html5_fragment("<span>foo</span><p>bar</p>").scrub!(span2div).to_s
606
+ # # => "<div>foo</div><p>bar</p>"
607
+ #
608
+ # or
609
+ #
610
+ # unsafe_html = "ohai! <div>div is safe</div> <script>but script is not</script>"
611
+ # Loofah.html5_fragment(unsafe_html).scrub!(:strip).to_s
612
+ # # => "ohai! <div>div is safe</div> "
613
+ #
614
+ # Note that this method is called implicitly from the shortcuts Loofah.scrub_html5_fragment et
615
+ # al.
616
+ #
617
+ # Please see Scrubber for more information on implementation and traversal, and README.rdoc for
618
+ # more example usage.
619
+ #
620
+ # pkg:gem/loofah#lib/loofah/concerns.rb:30
621
+ module Loofah::ScrubBehavior
622
+ class << self
623
+ # pkg:gem/loofah#lib/loofah/concerns.rb:59
624
+ def resolve_scrubber(scrubber); end
625
+ end
626
+ end
627
+
628
+ # pkg:gem/loofah#lib/loofah/concerns.rb:31
629
+ module Loofah::ScrubBehavior::Node
630
+ # pkg:gem/loofah#lib/loofah/concerns.rb:32
631
+ def scrub!(scrubber); end
632
+ end
633
+
634
+ # pkg:gem/loofah#lib/loofah/concerns.rb:51
635
+ module Loofah::ScrubBehavior::NodeSet
636
+ # pkg:gem/loofah#lib/loofah/concerns.rb:52
637
+ def scrub!(scrubber); end
638
+ end
639
+
640
+ # A Scrubber wraps up a block (or method) that is run on an HTML node (element):
641
+ #
642
+ # # change all <span> tags to <div> tags
643
+ # span2div = Loofah::Scrubber.new do |node|
644
+ # node.name = "div" if node.name == "span"
645
+ # end
646
+ #
647
+ # Alternatively, this scrubber could have been implemented as:
648
+ #
649
+ # class Span2Div < Loofah::Scrubber
650
+ # def scrub(node)
651
+ # node.name = "div" if node.name == "span"
652
+ # end
653
+ # end
654
+ # span2div = Span2Div.new
655
+ #
656
+ # This can then be run on a document:
657
+ #
658
+ # Loofah.html5_fragment("<span>foo</span><p>bar</p>").scrub!(span2div).to_s
659
+ # # => "<div>foo</div><p>bar</p>"
660
+ #
661
+ # Scrubbers can be run on a document in either a top-down traversal (the
662
+ # default) or bottom-up. Top-down scrubbers can optionally return
663
+ # Scrubber::STOP to terminate the traversal of a subtree.
664
+ #
665
+ # pkg:gem/loofah#lib/loofah/scrubber.rb:35
666
+ class Loofah::Scrubber
667
+ # Options may include
668
+ # :direction => :top_down (the default)
669
+ # or
670
+ # :direction => :bottom_up
671
+ #
672
+ # For top_down traversals, if the block returns
673
+ # Loofah::Scrubber::STOP, then the traversal will be terminated
674
+ # for the current node's subtree.
675
+ #
676
+ # Alternatively, a Scrubber may inherit from Loofah::Scrubber,
677
+ # and implement +scrub+, which is slightly faster than using a
678
+ # block.
679
+ #
680
+ # pkg:gem/loofah#lib/loofah/scrubber.rb:65
681
+ def initialize(options = T.unsafe(nil), &block); end
682
+
683
+ # If the attribute is not set, add it
684
+ # If the attribute is set, don't overwrite the existing value
685
+ #
686
+ # pkg:gem/loofah#lib/loofah/scrubber.rb:96
687
+ def append_attribute(node, attribute, value); end
688
+
689
+ # When a scrubber is initialized, the optional block is saved as
690
+ # :block. Note that, if no block is passed, then the +scrub+
691
+ # method is assumed to have been implemented.
692
+ #
693
+ # pkg:gem/loofah#lib/loofah/scrubber.rb:49
694
+ def block; end
695
+
696
+ # When a scrubber is initialized, the :direction may be specified
697
+ # as :top_down (the default) or :bottom_up.
698
+ #
699
+ # pkg:gem/loofah#lib/loofah/scrubber.rb:44
700
+ def direction; end
701
+
702
+ # When +new+ is not passed a block, the class may implement
703
+ # +scrub+, which will be called for each document node.
704
+ #
705
+ # pkg:gem/loofah#lib/loofah/scrubber.rb:88
706
+ def scrub(node); end
707
+
708
+ # Calling +traverse+ will cause the document to be traversed by
709
+ # either the lambda passed to the initializer or the +scrub+
710
+ # method, in the direction specified at +new+ time.
711
+ #
712
+ # pkg:gem/loofah#lib/loofah/scrubber.rb:80
713
+ def traverse(node); end
714
+
715
+ private
716
+
717
+ # pkg:gem/loofah#lib/loofah/scrubber.rb:105
718
+ def html5lib_sanitize(node); end
719
+
720
+ # pkg:gem/loofah#lib/loofah/scrubber.rb:131
721
+ def traverse_conditionally_bottom_up(node); end
722
+
723
+ # pkg:gem/loofah#lib/loofah/scrubber.rb:122
724
+ def traverse_conditionally_top_down(node); end
725
+ end
726
+
727
+ # Top-down Scrubbers may return CONTINUE to indicate that the subtree should be traversed.
728
+ #
729
+ # pkg:gem/loofah#lib/loofah/scrubber.rb:37
730
+ Loofah::Scrubber::CONTINUE = T.let(T.unsafe(nil), Object)
731
+
732
+ # Top-down Scrubbers may return STOP to indicate that the subtree should not be traversed.
733
+ #
734
+ # pkg:gem/loofah#lib/loofah/scrubber.rb:40
735
+ Loofah::Scrubber::STOP = T.let(T.unsafe(nil), Object)
736
+
737
+ # A RuntimeError raised when Loofah could not find an appropriate scrubber.
738
+ #
739
+ # pkg:gem/loofah#lib/loofah/scrubber.rb:7
740
+ class Loofah::ScrubberNotFound < ::RuntimeError; end
741
+
742
+ # Loofah provides some built-in scrubbers for sanitizing with
743
+ # HTML5lib's safelist and for accomplishing some common
744
+ # transformation tasks.
745
+ #
746
+ #
747
+ # === Loofah::Scrubbers::Strip / scrub!(:strip)
748
+ #
749
+ # +:strip+ removes unknown/unsafe tags, but leaves behind the pristine contents:
750
+ #
751
+ # unsafe_html = "ohai! <div>div is safe</div> <foo>but foo is <b>not</b></foo>"
752
+ # Loofah.html5_fragment(unsafe_html).scrub!(:strip)
753
+ # => "ohai! <div>div is safe</div> but foo is <b>not</b>"
754
+ #
755
+ #
756
+ # === Loofah::Scrubbers::Prune / scrub!(:prune)
757
+ #
758
+ # +:prune+ removes unknown/unsafe tags and their contents (including their subtrees):
759
+ #
760
+ # unsafe_html = "ohai! <div>div is safe</div> <foo>but foo is <b>not</b></foo>"
761
+ # Loofah.html5_fragment(unsafe_html).scrub!(:prune)
762
+ # => "ohai! <div>div is safe</div> "
763
+ #
764
+ #
765
+ # === Loofah::Scrubbers::Escape / scrub!(:escape)
766
+ #
767
+ # +:escape+ performs HTML entity escaping on the unknown/unsafe tags:
768
+ #
769
+ # unsafe_html = "ohai! <div>div is safe</div> <foo>but foo is <b>not</b></foo>"
770
+ # Loofah.html5_fragment(unsafe_html).scrub!(:escape)
771
+ # => "ohai! <div>div is safe</div> &lt;foo&gt;but foo is &lt;b&gt;not&lt;/b&gt;&lt;/foo&gt;"
772
+ #
773
+ #
774
+ # === Loofah::Scrubbers::Whitewash / scrub!(:whitewash)
775
+ #
776
+ # +:whitewash+ removes all comments, styling and attributes in
777
+ # addition to doing markup-fixer-uppery and pruning unsafe tags. I
778
+ # like to call this "whitewashing", since it's like putting a new
779
+ # layer of paint on top of the HTML input to make it look nice.
780
+ #
781
+ # messy_markup = "ohai! <div id='foo' class='bar' style='margin: 10px'>div with attributes</div>"
782
+ # Loofah.html5_fragment(messy_markup).scrub!(:whitewash)
783
+ # => "ohai! <div>div with attributes</div>"
784
+ #
785
+ # One use case for this scrubber is to clean up HTML that was
786
+ # cut-and-pasted from Microsoft Word into a WYSIWYG editor or a
787
+ # rich text editor. Microsoft's software is famous for injecting
788
+ # all kinds of cruft into its HTML output. Who needs that crap?
789
+ # Certainly not me.
790
+ #
791
+ #
792
+ # === Loofah::Scrubbers::NoFollow / scrub!(:nofollow)
793
+ #
794
+ # +:nofollow+ adds a rel="nofollow" attribute to all links
795
+ #
796
+ # link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
797
+ # Loofah.html5_fragment(link_farmers_markup).scrub!(:nofollow)
798
+ # => "ohai! <a href='http://www.myswarmysite.com/' rel="nofollow">I like your blog post</a>"
799
+ #
800
+ #
801
+ # === Loofah::Scrubbers::TargetBlank / scrub!(:targetblank)
802
+ #
803
+ # +:targetblank+ adds a target="_blank" attribute to all links
804
+ #
805
+ # link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
806
+ # Loofah.html5_fragment(link_farmers_markup).scrub!(:targetblank)
807
+ # => "ohai! <a href='http://www.myswarmysite.com/' target="_blank">I like your blog post</a>"
808
+ #
809
+ #
810
+ # === Loofah::Scrubbers::NoOpener / scrub!(:noopener)
811
+ #
812
+ # +:noopener+ adds a rel="noopener" attribute to all links
813
+ #
814
+ # link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
815
+ # Loofah.html5_fragment(link_farmers_markup).scrub!(:noopener)
816
+ # => "ohai! <a href='http://www.myswarmysite.com/' rel="noopener">I like your blog post</a>"
817
+ #
818
+ # === Loofah::Scrubbers::NoReferrer / scrub!(:noreferrer)
819
+ #
820
+ # +:noreferrer+ adds a rel="noreferrer" 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!(:noreferrer)
824
+ # => "ohai! <a href='http://www.myswarmysite.com/' rel="noreferrer">I like your blog post</a>"
825
+ #
826
+ #
827
+ # === Loofah::Scrubbers::Unprintable / scrub!(:unprintable)
828
+ #
829
+ # +:unprintable+ removes unprintable Unicode characters.
830
+ #
831
+ # markup = "<p>Some text with an unprintable character at the end\u2028</p>"
832
+ # Loofah.html5_fragment(markup).scrub!(:unprintable)
833
+ # => "<p>Some text with an unprintable character at the end</p>"
834
+ #
835
+ # You may not be able to see the unprintable character in the above example, but there is a
836
+ # U+2028 character right before the closing </p> tag. These characters can cause issues if
837
+ # the content is ever parsed by JavaScript - more information here:
838
+ #
839
+ # http://timelessrepo.com/json-isnt-a-javascript-subset
840
+ #
841
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:104
842
+ module Loofah::Scrubbers
843
+ class << self
844
+ # Returns an array of symbols representing the built-in scrubbers
845
+ #
846
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:425
847
+ def scrubber_symbols; end
848
+ end
849
+ end
850
+
851
+ # === scrub!(:double_breakpoint)
852
+ #
853
+ # +:double_breakpoint+ replaces double-break tags with closing/opening paragraph tags.
854
+ #
855
+ # markup = "<p>Some text here in a logical paragraph.<br><br>Some more text, apparently a second paragraph.</p>"
856
+ # Loofah.html5_fragment(markup).scrub!(:double_breakpoint)
857
+ # => "<p>Some text here in a logical paragraph.</p><p>Some more text, apparently a second paragraph.</p>"
858
+ #
859
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:362
860
+ class Loofah::Scrubbers::DoubleBreakpoint < ::Loofah::Scrubber
861
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:363
862
+ def initialize; end
863
+
864
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:367
865
+ def scrub(node); end
866
+
867
+ private
868
+
869
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:400
870
+ def remove_blank_text_nodes(node); end
871
+ end
872
+
873
+ # === scrub!(:escape)
874
+ #
875
+ # +:escape+ performs HTML entity escaping on the unknown/unsafe tags:
876
+ #
877
+ # unsafe_html = "ohai! <div>div is safe</div> <foo>but foo is <b>not</b></foo>"
878
+ # Loofah.html5_fragment(unsafe_html).scrub!(:escape)
879
+ # => "ohai! <div>div is safe</div> &lt;foo&gt;but foo is &lt;b&gt;not&lt;/b&gt;&lt;/foo&gt;"
880
+ #
881
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:159
882
+ class Loofah::Scrubbers::Escape < ::Loofah::Scrubber
883
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:160
884
+ def initialize; end
885
+
886
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:164
887
+ def scrub(node); end
888
+ end
889
+
890
+ # A hash that maps a symbol (like +:prune+) to the appropriate Scrubber (Loofah::Scrubbers::Prune).
891
+ #
892
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:407
893
+ Loofah::Scrubbers::MAP = T.let(T.unsafe(nil), Hash)
894
+
895
+ # This class probably isn't useful publicly, but is used for #to_text's current implemention
896
+ #
897
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:307
898
+ class Loofah::Scrubbers::NewlineBlockElements < ::Loofah::Scrubber
899
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:308
900
+ def initialize; end
901
+
902
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:312
903
+ def scrub(node); end
904
+ end
905
+
906
+ # === scrub!(:nofollow)
907
+ #
908
+ # +:nofollow+ adds a rel="nofollow" attribute to all links
909
+ #
910
+ # link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
911
+ # Loofah.html5_fragment(link_farmers_markup).scrub!(:nofollow)
912
+ # => "ohai! <a href='http://www.myswarmysite.com/' rel="nofollow">I like your blog post</a>"
913
+ #
914
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:220
915
+ class Loofah::Scrubbers::NoFollow < ::Loofah::Scrubber
916
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:221
917
+ def initialize; end
918
+
919
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:225
920
+ def scrub(node); end
921
+ end
922
+
923
+ # === scrub!(:noopener)
924
+ #
925
+ # +:noopener+ adds a rel="noopener" attribute to all links
926
+ #
927
+ # link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
928
+ # Loofah.html5_fragment(link_farmers_markup).scrub!(:noopener)
929
+ # => "ohai! <a href='http://www.myswarmysite.com/' rel="noopener">I like your blog post</a>"
930
+ #
931
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:271
932
+ class Loofah::Scrubbers::NoOpener < ::Loofah::Scrubber
933
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:272
934
+ def initialize; end
935
+
936
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:276
937
+ def scrub(node); end
938
+ end
939
+
940
+ # === scrub!(:noreferrer)
941
+ #
942
+ # +:noreferrer+ adds a rel="noreferrer" attribute to all links
943
+ #
944
+ # link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
945
+ # Loofah.html5_fragment(link_farmers_markup).scrub!(:noreferrer)
946
+ # => "ohai! <a href='http://www.myswarmysite.com/' rel="noreferrer">I like your blog post</a>"
947
+ #
948
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:293
949
+ class Loofah::Scrubbers::NoReferrer < ::Loofah::Scrubber
950
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:294
951
+ def initialize; end
952
+
953
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:298
954
+ def scrub(node); end
955
+ end
956
+
957
+ # === scrub!(:prune)
958
+ #
959
+ # +:prune+ removes unknown/unsafe tags and their contents (including their subtrees):
960
+ #
961
+ # unsafe_html = "ohai! <div>div is safe</div> <foo>but foo is <b>not</b></foo>"
962
+ # Loofah.html5_fragment(unsafe_html).scrub!(:prune)
963
+ # => "ohai! <div>div is safe</div> "
964
+ #
965
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:137
966
+ class Loofah::Scrubbers::Prune < ::Loofah::Scrubber
967
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:138
968
+ def initialize; end
969
+
970
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:142
971
+ def scrub(node); end
972
+ end
973
+
974
+ # === scrub!(:strip)
975
+ #
976
+ # +:strip+ removes unknown/unsafe tags, but leaves behind the pristine contents:
977
+ #
978
+ # unsafe_html = "ohai! <div>div is safe</div> <foo>but foo is <b>not</b></foo>"
979
+ # Loofah.html5_fragment(unsafe_html).scrub!(:strip)
980
+ # => "ohai! <div>div is safe</div> but foo is <b>not</b>"
981
+ #
982
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:114
983
+ class Loofah::Scrubbers::Strip < ::Loofah::Scrubber
984
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:115
985
+ def initialize; end
986
+
987
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:119
988
+ def scrub(node); end
989
+ end
990
+
991
+ # === scrub!(:targetblank)
992
+ #
993
+ # +:targetblank+ adds a target="_blank" attribute to all links.
994
+ # If there is a target already set, replaces it with target="_blank".
995
+ #
996
+ # link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
997
+ # Loofah.html5_fragment(link_farmers_markup).scrub!(:targetblank)
998
+ # => "ohai! <a href='http://www.myswarmysite.com/' target="_blank">I like your blog post</a>"
999
+ #
1000
+ # On modern browsers, setting target="_blank" on anchor elements implicitly provides the same
1001
+ # behavior as setting rel="noopener".
1002
+ #
1003
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:246
1004
+ class Loofah::Scrubbers::TargetBlank < ::Loofah::Scrubber
1005
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:247
1006
+ def initialize; end
1007
+
1008
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:251
1009
+ def scrub(node); end
1010
+ end
1011
+
1012
+ # === scrub!(:unprintable)
1013
+ #
1014
+ # +:unprintable+ removes unprintable Unicode characters.
1015
+ #
1016
+ # markup = "<p>Some text with an unprintable character at the end\u2028</p>"
1017
+ # Loofah.html5_fragment(markup).scrub!(:unprintable)
1018
+ # => "<p>Some text with an unprintable character at the end</p>"
1019
+ #
1020
+ # You may not be able to see the unprintable character in the above example, but there is a
1021
+ # U+2028 character right before the closing </p> tag. These characters can cause issues if
1022
+ # the content is ever parsed by JavaScript - more information here:
1023
+ #
1024
+ # http://timelessrepo.com/json-isnt-a-javascript-subset
1025
+ #
1026
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:340
1027
+ class Loofah::Scrubbers::Unprintable < ::Loofah::Scrubber
1028
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:341
1029
+ def initialize; end
1030
+
1031
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:345
1032
+ def scrub(node); end
1033
+ end
1034
+
1035
+ # === scrub!(:whitewash)
1036
+ #
1037
+ # +:whitewash+ removes all comments, styling and attributes in
1038
+ # addition to doing markup-fixer-uppery and pruning unsafe tags. I
1039
+ # like to call this "whitewashing", since it's like putting a new
1040
+ # layer of paint on top of the HTML input to make it look nice.
1041
+ #
1042
+ # messy_markup = "ohai! <div id='foo' class='bar' style='margin: 10px'>div with attributes</div>"
1043
+ # Loofah.html5_fragment(messy_markup).scrub!(:whitewash)
1044
+ # => "ohai! <div>div with attributes</div>"
1045
+ #
1046
+ # One use case for this scrubber is to clean up HTML that was
1047
+ # cut-and-pasted from Microsoft Word into a WYSIWYG editor or a
1048
+ # rich text editor. Microsoft's software is famous for injecting
1049
+ # all kinds of cruft into its HTML output. Who needs that crap?
1050
+ # Certainly not me.
1051
+ #
1052
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:191
1053
+ class Loofah::Scrubbers::Whitewash < ::Loofah::Scrubber
1054
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:192
1055
+ def initialize; end
1056
+
1057
+ # pkg:gem/loofah#lib/loofah/scrubbers.rb:196
1058
+ def scrub(node); end
1059
+ end
1060
+
1061
+ # Overrides +text+ in Document and DocumentFragment classes, and mixes in +to_text+.
1062
+ #
1063
+ # pkg:gem/loofah#lib/loofah/concerns.rb:73
1064
+ module Loofah::TextBehavior
1065
+ # pkg:gem/loofah#lib/loofah/concerns.rb:107
1066
+ def inner_text(options = T.unsafe(nil)); end
1067
+
1068
+ # Returns a plain-text version of the markup contained by the document, with HTML entities
1069
+ # encoded.
1070
+ #
1071
+ # This method is significantly faster than #to_text, but isn't clever about whitespace around
1072
+ # block elements.
1073
+ #
1074
+ # Loofah.html5_document("<h1>Title</h1><div>Content</div>").text
1075
+ # # => "TitleContent"
1076
+ #
1077
+ # By default, the returned text will have HTML entities escaped. If you want unescaped
1078
+ # entities, and you understand that the result is unsafe to render in a browser, then you can
1079
+ # pass an argument as shown:
1080
+ #
1081
+ # frag = Loofah.html5_fragment("&lt;script&gt;alert('EVIL');&lt;/script&gt;")
1082
+ # # ok for browser:
1083
+ # frag.text # => "&lt;script&gt;alert('EVIL');&lt;/script&gt;"
1084
+ # # decidedly not ok for browser:
1085
+ # frag.text(:encode_special_chars => false) # => "<script>alert('EVIL');</script>"
1086
+ #
1087
+ # pkg:gem/loofah#lib/loofah/concerns.rb:94
1088
+ def text(options = T.unsafe(nil)); end
1089
+
1090
+ # pkg:gem/loofah#lib/loofah/concerns.rb:108
1091
+ def to_str(options = T.unsafe(nil)); end
1092
+
1093
+ # Returns a plain-text version of the markup contained by the fragment, with HTML entities
1094
+ # encoded.
1095
+ #
1096
+ # This method is slower than #text, but is clever about whitespace around block elements and
1097
+ # line break elements.
1098
+ #
1099
+ # Loofah.html5_document("<h1>Title</h1><div>Content<br>Next line</div>").to_text
1100
+ # # => "\nTitle\n\nContent\nNext line\n"
1101
+ #
1102
+ # pkg:gem/loofah#lib/loofah/concerns.rb:120
1103
+ def to_text(options = T.unsafe(nil)); end
1104
+ end
1105
+
1106
+ # The version of Loofah you are using
1107
+ #
1108
+ # pkg:gem/loofah#lib/loofah/version.rb:5
1109
+ Loofah::VERSION = T.let(T.unsafe(nil), String)
1110
+
1111
+ # pkg:gem/loofah#lib/loofah/xml/document.rb:4
1112
+ module Loofah::XML; end
1113
+
1114
+ # Subclass of Nokogiri::XML::Document.
1115
+ #
1116
+ # See Loofah::ScrubBehavior and Loofah::DocumentDecorator for additional methods.
1117
+ #
1118
+ # pkg:gem/loofah#lib/loofah/xml/document.rb:10
1119
+ class Loofah::XML::Document < ::Nokogiri::XML::Document
1120
+ include ::Loofah::ScrubBehavior::Node
1121
+ include ::Loofah::DocumentDecorator
1122
+ end
1123
+
1124
+ # Subclass of Nokogiri::XML::DocumentFragment.
1125
+ #
1126
+ # See Loofah::ScrubBehavior for additional methods.
1127
+ #
1128
+ # pkg:gem/loofah#lib/loofah/xml/document_fragment.rb:10
1129
+ class Loofah::XML::DocumentFragment < ::Nokogiri::XML::DocumentFragment
1130
+ class << self
1131
+ # pkg:gem/loofah#lib/loofah/xml/document_fragment.rb:12
1132
+ def parse(tags); end
1133
+ end
1134
+ end