packwerk 3.2.3 → 3.3.1

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