brakeman 4.4.0 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of brakeman might be problematic. Click here for more details.

Files changed (362) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +17 -0
  3. data/bundle/load.rb +7 -8
  4. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/History.rdoc +8 -0
  5. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/Manifest.txt +0 -0
  6. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/README.rdoc +0 -0
  7. data/bundle/ruby/2.5.0/gems/{ruby2ruby-2.4.1 → ruby2ruby-2.4.2}/lib/ruby2ruby.rb +34 -36
  8. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/History.rdoc +47 -0
  9. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/Manifest.txt +5 -4
  10. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/README.rdoc +0 -0
  11. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/compare/normalize.rb +29 -2
  12. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/debugging.md +18 -0
  13. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/rp_extensions.rb +0 -7
  14. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/rp_stringscanner.rb +0 -0
  15. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby20_parser.rb +6874 -0
  16. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby20_parser.y +284 -201
  17. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby21_parser.rb +6952 -0
  18. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby21_parser.y +281 -197
  19. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby22_parser.rb +6983 -0
  20. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib/ruby_parser.yy → ruby_parser-3.13.0/lib/ruby22_parser.y} +280 -306
  21. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby23_parser.rb +6982 -0
  22. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby23_parser.y +282 -203
  23. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby24_parser.rb +6982 -0
  24. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby24_parser.y +282 -203
  25. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby25_parser.rb +6981 -0
  26. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby25_parser.y +282 -203
  27. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby26_parser.rb +6999 -0
  28. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby26_parser.y +2469 -0
  29. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_lexer.rb +116 -118
  30. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_lexer.rex +10 -8
  31. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_lexer.rex.rb +8 -8
  32. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0 → ruby_parser-3.13.0}/lib/ruby_parser.rb +5 -7
  33. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby_parser.yy +2571 -0
  34. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/lib/ruby_parser_extras.rb +1360 -0
  35. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/tools/munge.rb +216 -0
  36. data/bundle/ruby/2.5.0/gems/ruby_parser-3.13.0/tools/ripper.rb +23 -0
  37. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/History.rdoc +6 -0
  38. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/Manifest.txt +19 -0
  39. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/README.rdoc +54 -0
  40. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy.rb +5 -0
  41. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby18_parser.rb +7 -6
  42. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby18_parser.y +5 -4
  43. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby19_parser.rb +7 -6
  44. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby19_parser.y +5 -4
  45. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rb +1412 -0
  46. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rex +179 -0
  47. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rex.rb +323 -0
  48. data/bundle/ruby/2.5.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_parser.rb +30 -0
  49. data/bundle/ruby/2.5.0/gems/{ruby_parser-3.12.0/lib → ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy}/ruby_parser_extras.rb +43 -33
  50. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/CHANGES.md +5 -0
  51. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/Gemfile +0 -0
  52. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/LICENSE.txt +0 -0
  53. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/README.md +0 -0
  54. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/bundle_install_all_ruby_versions.sh +0 -0
  55. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml.rb +0 -0
  56. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/deep.rb +0 -0
  57. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/libyaml_checker.rb +0 -0
  58. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/load.rb +0 -0
  59. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/parse/date.rb +2 -0
  60. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/parse/hexadecimal.rb +0 -0
  61. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/parse/sexagesimal.rb +0 -0
  62. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/psych_handler.rb +0 -0
  63. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/psych_resolver.rb +0 -0
  64. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/resolver.rb +0 -0
  65. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/safe_to_ruby_visitor.rb +0 -0
  66. data/bundle/ruby/2.5.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb +39 -0
  67. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/syck_hack.rb +0 -0
  68. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/syck_node_monkeypatch.rb +0 -0
  69. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/syck_resolver.rb +0 -0
  70. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform.rb +0 -0
  71. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_boolean.rb +0 -0
  72. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_date.rb +0 -0
  73. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_float.rb +0 -0
  74. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_integer.rb +0 -0
  75. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_nil.rb +0 -0
  76. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/to_symbol.rb +0 -0
  77. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/transform/transformation_map.rb +0 -0
  78. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/lib/safe_yaml/version.rb +1 -1
  79. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/run_specs_all_ruby_versions.sh +0 -0
  80. data/bundle/ruby/2.5.0/gems/{safe_yaml-1.0.4 → safe_yaml-1.0.5}/safe_yaml.gemspec +0 -0
  81. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/History.rdoc +8 -0
  82. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/Manifest.txt +0 -0
  83. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/README.rdoc +0 -0
  84. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/composite_sexp_processor.rb +0 -0
  85. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/pt_testcase.rb +2 -2
  86. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/sexp.rb +4 -4
  87. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/sexp_processor.rb +1 -1
  88. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/strict_sexp.rb +3 -3
  89. data/bundle/ruby/2.5.0/gems/{sexp_processor-4.11.0 → sexp_processor-4.12.0}/lib/unique.rb +0 -0
  90. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/CHANGES +6 -0
  91. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/EXPRESSIONS.md +1 -1
  92. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/Gemfile +0 -0
  93. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/LICENSE +0 -0
  94. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/README.md +1 -1
  95. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple.rb +0 -0
  96. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/engine.rb +0 -0
  97. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/engine.rb +0 -0
  98. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/parser.rb +0 -0
  99. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/template.rb +0 -0
  100. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/erb/trimming.rb +0 -0
  101. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/exceptions.rb +0 -0
  102. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filter.rb +0 -0
  103. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/code_merger.rb +0 -0
  104. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/control_flow.rb +0 -0
  105. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/dynamic_inliner.rb +0 -0
  106. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/encoding.rb +0 -0
  107. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/eraser.rb +0 -0
  108. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/escapable.rb +0 -0
  109. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/multi_flattener.rb +0 -0
  110. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/remove_bom.rb +0 -0
  111. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/static_analyzer.rb +0 -0
  112. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/static_merger.rb +0 -0
  113. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/string_splitter.rb +0 -0
  114. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/filters/validator.rb +0 -0
  115. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generator.rb +0 -0
  116. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/array.rb +0 -0
  117. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/array_buffer.rb +0 -0
  118. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/erb.rb +0 -0
  119. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/rails_output_buffer.rb +0 -0
  120. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/generators/string_buffer.rb +0 -0
  121. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/grammar.rb +0 -0
  122. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/attribute_merger.rb +0 -0
  123. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/attribute_remover.rb +0 -0
  124. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/attribute_sorter.rb +0 -0
  125. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/dispatcher.rb +0 -0
  126. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/fast.rb +0 -0
  127. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/filter.rb +0 -0
  128. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/pretty.rb +0 -0
  129. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/html/safe.rb +0 -0
  130. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/map.rb +0 -0
  131. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/dispatcher.rb +2 -1
  132. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/engine_dsl.rb +0 -0
  133. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/grammar_dsl.rb +0 -0
  134. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/options.rb +0 -0
  135. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/mixins/template.rb +0 -0
  136. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/parser.rb +0 -0
  137. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/static_analyzer.rb +0 -0
  138. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/templates.rb +0 -0
  139. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/templates/rails.rb +2 -2
  140. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/templates/tilt.rb +0 -0
  141. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/lib/temple/utils.rb +0 -0
  142. data/bundle/ruby/2.5.0/gems/temple-0.8.1/lib/temple/version.rb +3 -0
  143. data/bundle/ruby/2.5.0/gems/{temple-0.8.0 → temple-0.8.1}/temple.gemspec +0 -0
  144. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/CHANGELOG.md +4 -0
  145. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/MIT-LICENSE.txt +1 -1
  146. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/README.md +10 -10
  147. data/bundle/ruby/2.5.0/gems/unicode-display_width-1.5.0/data/display_width.marshal.gz +0 -0
  148. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width.rb +0 -0
  149. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/constants.rb +2 -2
  150. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/index.rb +0 -0
  151. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/no_string_ext.rb +0 -0
  152. data/bundle/ruby/2.5.0/gems/{unicode-display_width-1.4.1 → unicode-display_width-1.5.0}/lib/unicode/display_width/string_ext.rb +0 -0
  153. data/lib/brakeman/checks/base_check.rb +16 -0
  154. data/lib/brakeman/checks/check_content_tag.rb +12 -0
  155. data/lib/brakeman/checks/check_cross_site_scripting.rb +6 -6
  156. data/lib/brakeman/checks/check_evaluation.rb +0 -1
  157. data/lib/brakeman/checks/check_execute.rb +18 -0
  158. data/lib/brakeman/checks/check_send.rb +0 -1
  159. data/lib/brakeman/checks/check_session_manipulation.rb +0 -1
  160. data/lib/brakeman/checks/check_sql.rb +12 -3
  161. data/lib/brakeman/file_parser.rb +8 -4
  162. data/lib/brakeman/parsers/haml_embedded.rb +44 -0
  163. data/lib/brakeman/parsers/slim_embedded.rb +44 -0
  164. data/lib/brakeman/parsers/template_parser.rb +2 -4
  165. data/lib/brakeman/processors/alias_processor.rb +23 -1
  166. data/lib/brakeman/processors/lib/call_conversion_helper.rb +4 -0
  167. data/lib/brakeman/processors/slim_template_processor.rb +16 -0
  168. data/lib/brakeman/processors/template_alias_processor.rb +2 -2
  169. data/lib/brakeman/scanner.rb +11 -10
  170. data/lib/brakeman/tracker.rb +5 -1
  171. data/lib/brakeman/tracker/config.rb +32 -7
  172. data/lib/brakeman/util.rb +17 -0
  173. data/lib/brakeman/version.rb +1 -1
  174. metadata +157 -320
  175. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby20_parser.rb +0 -6687
  176. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby21_parser.rb +0 -6767
  177. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby22_parser.rb +0 -6803
  178. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby22_parser.y +0 -2376
  179. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby23_parser.rb +0 -6818
  180. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby24_parser.rb +0 -6818
  181. data/bundle/ruby/2.5.0/gems/ruby_parser-3.12.0/lib/ruby25_parser.rb +0 -6818
  182. data/bundle/ruby/2.5.0/gems/sass-3.4.25/CODE_OF_CONDUCT.md +0 -10
  183. data/bundle/ruby/2.5.0/gems/sass-3.4.25/CONTRIBUTING.md +0 -148
  184. data/bundle/ruby/2.5.0/gems/sass-3.4.25/MIT-LICENSE +0 -20
  185. data/bundle/ruby/2.5.0/gems/sass-3.4.25/README.md +0 -227
  186. data/bundle/ruby/2.5.0/gems/sass-3.4.25/REVISION +0 -1
  187. data/bundle/ruby/2.5.0/gems/sass-3.4.25/VERSION +0 -1
  188. data/bundle/ruby/2.5.0/gems/sass-3.4.25/VERSION_DATE +0 -1
  189. data/bundle/ruby/2.5.0/gems/sass-3.4.25/VERSION_NAME +0 -1
  190. data/bundle/ruby/2.5.0/gems/sass-3.4.25/extra/sass-spec-ref.sh +0 -32
  191. data/bundle/ruby/2.5.0/gems/sass-3.4.25/extra/update_watch.rb +0 -13
  192. data/bundle/ruby/2.5.0/gems/sass-3.4.25/init.rb +0 -18
  193. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass.rb +0 -109
  194. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores.rb +0 -15
  195. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/base.rb +0 -88
  196. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/chain.rb +0 -34
  197. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/filesystem.rb +0 -60
  198. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/memory.rb +0 -46
  199. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/cache_stores/null.rb +0 -25
  200. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/callbacks.rb +0 -67
  201. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/css.rb +0 -408
  202. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/deprecation.rb +0 -55
  203. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/engine.rb +0 -1226
  204. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/environment.rb +0 -215
  205. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/error.rb +0 -198
  206. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec.rb +0 -9
  207. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec/base.rb +0 -199
  208. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec/sass_convert.rb +0 -283
  209. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/exec/sass_scss.rb +0 -440
  210. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/features.rb +0 -47
  211. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers.rb +0 -23
  212. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers/base.rb +0 -182
  213. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers/deprecated_path.rb +0 -51
  214. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/importers/filesystem.rb +0 -219
  215. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger.rb +0 -17
  216. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger/base.rb +0 -36
  217. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger/delayed.rb +0 -50
  218. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/logger/log_level.rb +0 -45
  219. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/media.rb +0 -210
  220. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin.rb +0 -134
  221. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/compiler.rb +0 -582
  222. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/configuration.rb +0 -134
  223. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/generic.rb +0 -15
  224. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/merb.rb +0 -48
  225. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/rack.rb +0 -60
  226. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/rails.rb +0 -47
  227. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/plugin/staleness_checker.rb +0 -199
  228. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/railtie.rb +0 -10
  229. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/repl.rb +0 -57
  230. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/root.rb +0 -7
  231. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script.rb +0 -66
  232. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/css_lexer.rb +0 -33
  233. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/css_parser.rb +0 -33
  234. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/css_variable_warning.rb +0 -52
  235. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/functions.rb +0 -2693
  236. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/lexer.rb +0 -464
  237. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/parser.rb +0 -832
  238. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree.rb +0 -16
  239. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/funcall.rb +0 -313
  240. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/interpolation.rb +0 -223
  241. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/list_literal.rb +0 -104
  242. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/literal.rb +0 -49
  243. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/map_literal.rb +0 -64
  244. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/node.rb +0 -127
  245. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/operation.rb +0 -156
  246. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/selector.rb +0 -26
  247. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/string_interpolation.rb +0 -125
  248. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/unary_operation.rb +0 -69
  249. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/tree/variable.rb +0 -57
  250. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value.rb +0 -11
  251. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/arg_list.rb +0 -36
  252. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/base.rb +0 -241
  253. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/bool.rb +0 -35
  254. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/color.rb +0 -698
  255. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/helpers.rb +0 -272
  256. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/list.rb +0 -113
  257. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/map.rb +0 -70
  258. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/null.rb +0 -44
  259. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/number.rb +0 -563
  260. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/script/value/string.rb +0 -138
  261. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss.rb +0 -14
  262. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/css_parser.rb +0 -56
  263. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/parser.rb +0 -1254
  264. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/rx.rb +0 -140
  265. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/scss/static_parser.rb +0 -373
  266. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector.rb +0 -323
  267. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/abstract_sequence.rb +0 -111
  268. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/comma_sequence.rb +0 -191
  269. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/pseudo.rb +0 -266
  270. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/sequence.rb +0 -636
  271. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/simple.rb +0 -117
  272. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/selector/simple_sequence.rb +0 -344
  273. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/shared.rb +0 -76
  274. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/source/map.rb +0 -213
  275. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/source/position.rb +0 -39
  276. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/source/range.rb +0 -41
  277. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/stack.rb +0 -120
  278. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/supports.rb +0 -225
  279. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/at_root_node.rb +0 -83
  280. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/charset_node.rb +0 -22
  281. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/comment_node.rb +0 -82
  282. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/content_node.rb +0 -9
  283. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/css_import_node.rb +0 -68
  284. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/debug_node.rb +0 -18
  285. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/directive_node.rb +0 -59
  286. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/each_node.rb +0 -24
  287. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/error_node.rb +0 -18
  288. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/extend_node.rb +0 -43
  289. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/for_node.rb +0 -36
  290. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/function_node.rb +0 -44
  291. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/if_node.rb +0 -52
  292. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/import_node.rb +0 -75
  293. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/keyframe_rule_node.rb +0 -15
  294. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/media_node.rb +0 -48
  295. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/mixin_def_node.rb +0 -38
  296. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/mixin_node.rb +0 -52
  297. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/node.rb +0 -240
  298. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/prop_node.rb +0 -170
  299. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/return_node.rb +0 -19
  300. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/root_node.rb +0 -44
  301. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/rule_node.rb +0 -155
  302. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/supports_node.rb +0 -38
  303. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/trace_node.rb +0 -33
  304. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/variable_node.rb +0 -36
  305. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/base.rb +0 -72
  306. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/check_nesting.rb +0 -173
  307. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/convert.rb +0 -351
  308. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/cssize.rb +0 -373
  309. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/deep_copy.rb +0 -107
  310. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/extend.rb +0 -70
  311. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/perform.rb +0 -564
  312. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/set_options.rb +0 -139
  313. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/visitors/to_css.rb +0 -409
  314. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/warn_node.rb +0 -18
  315. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/tree/while_node.rb +0 -18
  316. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util.rb +0 -1375
  317. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/cross_platform_random.rb +0 -19
  318. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/multibyte_string_scanner.rb +0 -155
  319. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/normalized_map.rb +0 -129
  320. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/ordered_hash.rb +0 -192
  321. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/subset_map.rb +0 -109
  322. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/util/test.rb +0 -9
  323. data/bundle/ruby/2.5.0/gems/sass-3.4.25/lib/sass/version.rb +0 -124
  324. data/bundle/ruby/2.5.0/gems/sass-3.4.25/rails/init.rb +0 -1
  325. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/CHANGELOG.md +0 -1
  326. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/CONTRIBUTING.md +0 -38
  327. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Gemfile +0 -20
  328. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Guardfile +0 -8
  329. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/LICENSE +0 -20
  330. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/README.md +0 -349
  331. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Rakefile +0 -5
  332. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/Vagrantfile +0 -96
  333. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen.rb +0 -54
  334. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapter.rb +0 -327
  335. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/bsd.rb +0 -75
  336. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/darwin.rb +0 -48
  337. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/linux.rb +0 -81
  338. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/polling.rb +0 -58
  339. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/adapters/windows.rb +0 -91
  340. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/directory_record.rb +0 -406
  341. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/listener.rb +0 -323
  342. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/turnstile.rb +0 -32
  343. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/lib/listen/version.rb +0 -3
  344. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/listen.gemspec +0 -28
  345. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapter_spec.rb +0 -149
  346. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
  347. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -37
  348. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -47
  349. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  350. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -30
  351. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/directory_record_spec.rb +0 -1250
  352. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/listener_spec.rb +0 -258
  353. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  354. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/listen_spec.rb +0 -67
  355. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/spec_helper.rb +0 -25
  356. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/adapter_helper.rb +0 -666
  357. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/directory_record_helper.rb +0 -57
  358. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  359. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/listeners_helper.rb +0 -179
  360. data/bundle/ruby/2.5.0/gems/sass-3.4.25/vendor/listen/spec/support/platform_helper.rb +0 -15
  361. data/bundle/ruby/2.5.0/gems/temple-0.8.0/lib/temple/version.rb +0 -3
  362. data/bundle/ruby/2.5.0/gems/unicode-display_width-1.4.1/data/display_width.marshal.gz +0 -0
@@ -1,266 +0,0 @@
1
- module Sass
2
- module Selector
3
- # A pseudoclass (e.g. `:visited`) or pseudoelement (e.g. `::first-line`)
4
- # selector. It can have arguments (e.g. `:nth-child(2n+1)`) which can
5
- # contain selectors (e.g. `:nth-child(2n+1 of .foo)`).
6
- class Pseudo < Simple
7
- # Some pseudo-class-syntax selectors are actually considered
8
- # pseudo-elements and must be treated differently. This is a list of such
9
- # selectors.
10
- #
11
- # @return [Set<String>]
12
- ACTUALLY_ELEMENTS = %w(after before first-line first-letter).to_set
13
-
14
- # Like \{#type}, but returns the type of selector this looks like, rather
15
- # than the type it is semantically. This only differs from type for
16
- # selectors in \{ACTUALLY\_ELEMENTS}.
17
- #
18
- # @return [Symbol]
19
- attr_reader :syntactic_type
20
-
21
- # The name of the selector.
22
- #
23
- # @return [String]
24
- attr_reader :name
25
-
26
- # The argument to the selector,
27
- # or `nil` if no argument was given.
28
- #
29
- # @return [String, nil]
30
- attr_reader :arg
31
-
32
- # The selector argument, or `nil` if no selector exists.
33
- #
34
- # If this and \{#arg\} are both set, \{#arg\} is considered a non-selector
35
- # prefix.
36
- #
37
- # @return [CommaSequence]
38
- attr_reader :selector
39
-
40
- # @param syntactic_type [Symbol] See \{#syntactic_type}
41
- # @param name [String] See \{#name}
42
- # @param arg [nil, String] See \{#arg}
43
- # @param selector [nil, CommaSequence] See \{#selector}
44
- def initialize(syntactic_type, name, arg, selector)
45
- @syntactic_type = syntactic_type
46
- @name = name
47
- @arg = arg
48
- @selector = selector
49
- end
50
-
51
- # Returns a copy of this with \{#selector} set to \{#new\_selector}.
52
- #
53
- # @param new_selector [CommaSequence]
54
- # @return [Array<Simple>]
55
- def with_selector(new_selector)
56
- result = Pseudo.new(syntactic_type, name, arg,
57
- CommaSequence.new(new_selector.members.map do |seq|
58
- next seq unless seq.members.length == 1
59
- sseq = seq.members.first
60
- next seq unless sseq.is_a?(SimpleSequence) && sseq.members.length == 1
61
- sel = sseq.members.first
62
- next seq unless sel.is_a?(Pseudo) && sel.selector
63
-
64
- case normalized_name
65
- when 'not'
66
- # In theory, if there's a nested :not its contents should be
67
- # unified with the return value. For example, if :not(.foo)
68
- # extends .bar, :not(.bar) should become .foo:not(.bar). However,
69
- # this is a narrow edge case and supporting it properly would make
70
- # this code and the code calling it a lot more complicated, so
71
- # it's not supported for now.
72
- next [] unless sel.normalized_name == 'matches'
73
- sel.selector.members
74
- when 'matches', 'any', 'current', 'nth-child', 'nth-last-child'
75
- # As above, we could theoretically support :not within :matches, but
76
- # doing so would require this method and its callers to handle much
77
- # more complex cases that likely aren't worth the pain.
78
- next [] unless sel.name == name && sel.arg == arg
79
- sel.selector.members
80
- when 'has', 'host', 'host-context'
81
- # We can't expand nested selectors here, because each layer adds an
82
- # additional layer of semantics. For example, `:has(:has(img))`
83
- # doesn't match `<div><img></div>` but `:has(img)` does.
84
- sel
85
- else
86
- []
87
- end
88
- end.flatten))
89
-
90
- # Older browsers support :not but only with a single complex selector.
91
- # In order to support those browsers, we break up the contents of a :not
92
- # unless it originally contained a selector list.
93
- return [result] unless normalized_name == 'not'
94
- return [result] if selector.members.length > 1
95
- result.selector.members.map do |seq|
96
- Pseudo.new(syntactic_type, name, arg, CommaSequence.new([seq]))
97
- end
98
- end
99
-
100
- # The type of the selector. `:class` if this is a pseudoclass selector,
101
- # `:element` if it's a pseudoelement.
102
- #
103
- # @return [Symbol]
104
- def type
105
- ACTUALLY_ELEMENTS.include?(normalized_name) ? :element : syntactic_type
106
- end
107
-
108
- # Like \{#name\}, but without any vendor prefix.
109
- #
110
- # @return [String]
111
- def normalized_name
112
- @normalized_name ||= name.gsub(/^-[a-zA-Z0-9]+-/, '')
113
- end
114
-
115
- # @see Selector#to_s
116
- def to_s(opts = {})
117
- res = (syntactic_type == :class ? ":" : "::") + @name
118
- if @arg || @selector
119
- res << "("
120
- res << @arg.strip if @arg
121
- res << " " if @arg && @selector
122
- res << @selector.to_s(opts) if @selector
123
- res << ")"
124
- end
125
- res
126
- end
127
-
128
- # Returns `nil` if this is a pseudoelement selector
129
- # and `sels` contains a pseudoelement selector different than this one.
130
- #
131
- # @see SimpleSequence#unify
132
- def unify(sels)
133
- return if type == :element && sels.any? do |sel|
134
- sel.is_a?(Pseudo) && sel.type == :element &&
135
- (sel.name != name || sel.arg != arg || sel.selector != selector)
136
- end
137
- super
138
- end
139
-
140
- # Returns whether or not this selector matches all elements
141
- # that the given selector matches (as well as possibly more).
142
- #
143
- # @example
144
- # (.foo).superselector?(.foo.bar) #=> true
145
- # (.foo).superselector?(.bar) #=> false
146
- # @param their_sseq [SimpleSequence]
147
- # @param parents [Array<SimpleSequence, String>] The parent selectors of `their_sseq`, if any.
148
- # @return [Boolean]
149
- def superselector?(their_sseq, parents = [])
150
- case normalized_name
151
- when 'matches', 'any'
152
- # :matches can be a superselector of another selector in one of two
153
- # ways. Either its constituent selectors can be a superset of those of
154
- # another :matches in the other selector, or any of its constituent
155
- # selectors can individually be a superselector of the other selector.
156
- (their_sseq.selector_pseudo_classes[normalized_name] || []).any? do |their_sel|
157
- next false unless their_sel.is_a?(Pseudo)
158
- next false unless their_sel.name == name
159
- selector.superselector?(their_sel.selector)
160
- end || selector.members.any? do |our_seq|
161
- their_seq = Sequence.new(parents + [their_sseq])
162
- our_seq.superselector?(their_seq)
163
- end
164
- when 'has', 'host', 'host-context'
165
- # Like :matches, :has (et al) can be a superselector of another
166
- # selector if its constituent selectors are a superset of those of
167
- # another :has in the other selector. However, the :matches other case
168
- # doesn't work, because :has refers to nested elements.
169
- (their_sseq.selector_pseudo_classes[normalized_name] || []).any? do |their_sel|
170
- next false unless their_sel.is_a?(Pseudo)
171
- next false unless their_sel.name == name
172
- selector.superselector?(their_sel.selector)
173
- end
174
- when 'not'
175
- selector.members.all? do |our_seq|
176
- their_sseq.members.any? do |their_sel|
177
- if their_sel.is_a?(Element) || their_sel.is_a?(Id)
178
- # `:not(a)` is a superselector of `h1` and `:not(#foo)` is a
179
- # superselector of `#bar`.
180
- our_sseq = our_seq.members.last
181
- next false unless our_sseq.is_a?(SimpleSequence)
182
- our_sseq.members.any? do |our_sel|
183
- our_sel.class == their_sel.class && our_sel != their_sel
184
- end
185
- else
186
- next false unless their_sel.is_a?(Pseudo)
187
- next false unless their_sel.name == name
188
- # :not(X) is a superselector of :not(Y) exactly when Y is a
189
- # superselector of X.
190
- their_sel.selector.superselector?(CommaSequence.new([our_seq]))
191
- end
192
- end
193
- end
194
- when 'current'
195
- (their_sseq.selector_pseudo_classes['current'] || []).any? do |their_current|
196
- next false if their_current.name != name
197
- # Explicitly don't check for nested superselector relationships
198
- # here. :current(.foo) isn't always a superselector of
199
- # :current(.foo.bar), since it matches the *innermost* ancestor of
200
- # the current element that matches the selector. For example:
201
- #
202
- # <div class="foo bar">
203
- # <p class="foo">
204
- # <span>current element</span>
205
- # </p>
206
- # </div>
207
- #
208
- # Here :current(.foo) would match the p element and *not* the div
209
- # element, whereas :current(.foo.bar) would match the div and not
210
- # the p.
211
- selector == their_current.selector
212
- end
213
- when 'nth-child', 'nth-last-child'
214
- their_sseq.members.any? do |their_sel|
215
- # This misses a few edge cases. For example, `:nth-child(n of X)`
216
- # is a superselector of `X`, and `:nth-child(2n of X)` is a
217
- # superselector of `:nth-child(4n of X)`. These seem rare enough
218
- # not to be worth worrying about, though.
219
- next false unless their_sel.is_a?(Pseudo)
220
- next false unless their_sel.name == name
221
- next false unless their_sel.arg == arg
222
- selector.superselector?(their_sel.selector)
223
- end
224
- else
225
- throw "[BUG] Unknown selector pseudo class #{name}"
226
- end
227
- end
228
-
229
- # @see AbstractSequence#specificity
230
- def specificity
231
- return 1 if type == :element
232
- return SPECIFICITY_BASE unless selector
233
- @specificity ||=
234
- if normalized_name == 'not'
235
- min = 0
236
- max = 0
237
- selector.members.each do |seq|
238
- spec = seq.specificity
239
- if spec.is_a?(Range)
240
- min = Sass::Util.max(spec.begin, min)
241
- max = Sass::Util.max(spec.end, max)
242
- else
243
- min = Sass::Util.max(spec, min)
244
- max = Sass::Util.max(spec, max)
245
- end
246
- end
247
- min == max ? max : (min..max)
248
- else
249
- min = 0
250
- max = 0
251
- selector.members.each do |seq|
252
- spec = seq.specificity
253
- if spec.is_a?(Range)
254
- min = Sass::Util.min(spec.begin, min)
255
- max = Sass::Util.max(spec.end, max)
256
- else
257
- min = Sass::Util.min(spec, min)
258
- max = Sass::Util.max(spec, max)
259
- end
260
- end
261
- min == max ? max : (min..max)
262
- end
263
- end
264
- end
265
- end
266
- end
@@ -1,636 +0,0 @@
1
- module Sass
2
- module Selector
3
- # An operator-separated sequence of
4
- # {SimpleSequence simple selector sequences}.
5
- class Sequence < AbstractSequence
6
- # Sets the line of the Sass template on which this selector was declared.
7
- # This also sets the line for all child selectors.
8
- #
9
- # @param line [Integer]
10
- # @return [Integer]
11
- def line=(line)
12
- members.each {|m| m.line = line if m.is_a?(SimpleSequence)}
13
- @line = line
14
- end
15
-
16
- # Sets the name of the file in which this selector was declared,
17
- # or `nil` if it was not declared in a file (e.g. on stdin).
18
- # This also sets the filename for all child selectors.
19
- #
20
- # @param filename [String, nil]
21
- # @return [String, nil]
22
- def filename=(filename)
23
- members.each {|m| m.filename = filename if m.is_a?(SimpleSequence)}
24
- filename
25
- end
26
-
27
- # The array of {SimpleSequence simple selector sequences}, operators, and
28
- # newlines. The operators are strings such as `"+"` and `">"` representing
29
- # the corresponding CSS operators, or interpolated SassScript. Newlines
30
- # are also newline strings; these aren't semantically relevant, but they
31
- # do affect formatting.
32
- #
33
- # @return [Array<SimpleSequence, String|Array<Sass::Tree::Node, String>>]
34
- attr_reader :members
35
-
36
- # @param seqs_and_ops [Array<SimpleSequence, String|Array<Sass::Tree::Node, String>>]
37
- # See \{#members}
38
- def initialize(seqs_and_ops)
39
- @members = seqs_and_ops
40
- end
41
-
42
- # Resolves the {Parent} selectors within this selector
43
- # by replacing them with the given parent selector,
44
- # handling commas appropriately.
45
- #
46
- # @param super_cseq [CommaSequence] The parent selector
47
- # @param implicit_parent [Boolean] Whether the the parent
48
- # selector should automatically be prepended to the resolved
49
- # selector if it contains no parent refs.
50
- # @return [CommaSequence] This selector, with parent references resolved
51
- # @raise [Sass::SyntaxError] If a parent selector is invalid
52
- def resolve_parent_refs(super_cseq, implicit_parent)
53
- members = @members.dup
54
- nl = (members.first == "\n" && members.shift)
55
- contains_parent_ref = contains_parent_ref?
56
- return CommaSequence.new([self]) if !implicit_parent && !contains_parent_ref
57
-
58
- unless contains_parent_ref
59
- old_members, members = members, []
60
- members << nl if nl
61
- members << SimpleSequence.new([Parent.new], false)
62
- members += old_members
63
- end
64
-
65
- CommaSequence.new(Sass::Util.paths(members.map do |sseq_or_op|
66
- next [sseq_or_op] unless sseq_or_op.is_a?(SimpleSequence)
67
- sseq_or_op.resolve_parent_refs(super_cseq).members
68
- end).map do |path|
69
- Sequence.new(path.map do |seq_or_op|
70
- next seq_or_op unless seq_or_op.is_a?(Sequence)
71
- seq_or_op.members
72
- end.flatten)
73
- end)
74
- end
75
-
76
- # Returns whether there's a {Parent} selector anywhere in this sequence.
77
- #
78
- # @return [Boolean]
79
- def contains_parent_ref?
80
- members.any? do |sseq_or_op|
81
- next false unless sseq_or_op.is_a?(SimpleSequence)
82
- next true if sseq_or_op.members.first.is_a?(Parent)
83
- sseq_or_op.members.any? do |sel|
84
- sel.is_a?(Pseudo) && sel.selector && sel.selector.contains_parent_ref?
85
- end
86
- end
87
- end
88
-
89
- # Non-destructively extends this selector with the extensions specified in a hash
90
- # (which should come from {Sass::Tree::Visitors::Cssize}).
91
- #
92
- # @param extends [Sass::Util::SubsetMap{Selector::Simple =>
93
- # Sass::Tree::Visitors::Cssize::Extend}]
94
- # The extensions to perform on this selector
95
- # @param parent_directives [Array<Sass::Tree::DirectiveNode>]
96
- # The directives containing this selector.
97
- # @param replace [Boolean]
98
- # Whether to replace the original selector entirely or include
99
- # it in the result.
100
- # @param seen [Set<Array<Selector::Simple>>]
101
- # The set of simple sequences that are currently being replaced.
102
- # @param original [Boolean]
103
- # Whether this is the original selector being extended, as opposed to
104
- # the result of a previous extension that's being re-extended.
105
- # @return [Array<Sequence>] A list of selectors generated
106
- # by extending this selector with `extends`.
107
- # These correspond to a {CommaSequence}'s {CommaSequence#members members array}.
108
- # @see CommaSequence#do_extend
109
- def do_extend(extends, parent_directives, replace, seen, original)
110
- extended_not_expanded = members.map do |sseq_or_op|
111
- next [[sseq_or_op]] unless sseq_or_op.is_a?(SimpleSequence)
112
- extended = sseq_or_op.do_extend(extends, parent_directives, replace, seen)
113
-
114
- # The First Law of Extend says that the generated selector should have
115
- # specificity greater than or equal to that of the original selector.
116
- # In order to ensure that, we record the original selector's
117
- # (`extended.first`) original specificity.
118
- extended.first.add_sources!([self]) if original && !has_placeholder?
119
-
120
- extended.map {|seq| seq.members}
121
- end
122
- weaves = Sass::Util.paths(extended_not_expanded).map {|path| weave(path)}
123
- trim(weaves).map {|p| Sequence.new(p)}
124
- end
125
-
126
- # Unifies this with another selector sequence to produce a selector
127
- # that matches (a subset of) the intersection of the two inputs.
128
- #
129
- # @param other [Sequence]
130
- # @return [CommaSequence, nil] The unified selector, or nil if unification failed.
131
- # @raise [Sass::SyntaxError] If this selector cannot be unified.
132
- # This will only ever occur when a dynamic selector,
133
- # such as {Parent} or {Interpolation}, is used in unification.
134
- # Since these selectors should be resolved
135
- # by the time extension and unification happen,
136
- # this exception will only ever be raised as a result of programmer error
137
- def unify(other)
138
- base = members.last
139
- other_base = other.members.last
140
- return unless base.is_a?(SimpleSequence) && other_base.is_a?(SimpleSequence)
141
- return unless (unified = other_base.unify(base))
142
-
143
- woven = weave([members[0...-1], other.members[0...-1] + [unified]])
144
- CommaSequence.new(woven.map {|w| Sequence.new(w)})
145
- end
146
-
147
- # Returns whether or not this selector matches all elements
148
- # that the given selector matches (as well as possibly more).
149
- #
150
- # @example
151
- # (.foo).superselector?(.foo.bar) #=> true
152
- # (.foo).superselector?(.bar) #=> false
153
- # @param cseq [Sequence]
154
- # @return [Boolean]
155
- def superselector?(seq)
156
- _superselector?(members, seq.members)
157
- end
158
-
159
- # @see AbstractSequence#to_s
160
- def to_s(opts = {})
161
- @members.map {|m| m.is_a?(String) ? m : m.to_s(opts)}.join(" ").gsub(/ ?\n ?/, "\n")
162
- end
163
-
164
- # Returns a string representation of the sequence.
165
- # This is basically the selector string.
166
- #
167
- # @return [String]
168
- def inspect
169
- members.map {|m| m.inspect}.join(" ")
170
- end
171
-
172
- # Add to the {SimpleSequence#sources} sets of the child simple sequences.
173
- # This destructively modifies this sequence's members array, but not the
174
- # child simple sequences.
175
- #
176
- # @param sources [Set<Sequence>]
177
- def add_sources!(sources)
178
- members.map! {|m| m.is_a?(SimpleSequence) ? m.with_more_sources(sources) : m}
179
- end
180
-
181
- # Converts the subject operator "!", if it exists, into a ":has()"
182
- # selector.
183
- #
184
- # @retur [Sequence]
185
- def subjectless
186
- pre_subject = []
187
- has = []
188
- subject = nil
189
- members.each do |sseq_or_op|
190
- if subject
191
- has << sseq_or_op
192
- elsif sseq_or_op.is_a?(String) || !sseq_or_op.subject?
193
- pre_subject << sseq_or_op
194
- else
195
- subject = sseq_or_op.dup
196
- subject.members = sseq_or_op.members.dup
197
- subject.subject = false
198
- has = []
199
- end
200
- end
201
-
202
- return self unless subject
203
-
204
- unless has.empty?
205
- subject.members << Pseudo.new(:class, 'has', nil, CommaSequence.new([Sequence.new(has)]))
206
- end
207
- Sequence.new(pre_subject + [subject])
208
- end
209
-
210
- private
211
-
212
- # Conceptually, this expands "parenthesized selectors". That is, if we
213
- # have `.A .B {@extend .C}` and `.D .C {...}`, this conceptually expands
214
- # into `.D .C, .D (.A .B)`, and this function translates `.D (.A .B)` into
215
- # `.D .A .B, .A .D .B`. For thoroughness, `.A.D .B` would also be
216
- # required, but including merged selectors results in exponential output
217
- # for very little gain.
218
- #
219
- # @param path [Array<Array<SimpleSequence or String>>]
220
- # A list of parenthesized selector groups.
221
- # @return [Array<Array<SimpleSequence or String>>] A list of fully-expanded selectors.
222
- def weave(path)
223
- # This function works by moving through the selector path left-to-right,
224
- # building all possible prefixes simultaneously.
225
- prefixes = [[]]
226
-
227
- path.each do |current|
228
- next if current.empty?
229
- current = current.dup
230
- last_current = [current.pop]
231
- prefixes = prefixes.map do |prefix|
232
- sub = subweave(prefix, current)
233
- next [] unless sub
234
- sub.map {|seqs| seqs + last_current}
235
- end.flatten(1)
236
- end
237
- prefixes
238
- end
239
-
240
- # This interweaves two lists of selectors,
241
- # returning all possible orderings of them (including using unification)
242
- # that maintain the relative ordering of the input arrays.
243
- #
244
- # For example, given `.foo .bar` and `.baz .bang`,
245
- # this would return `.foo .bar .baz .bang`, `.foo .bar.baz .bang`,
246
- # `.foo .baz .bar .bang`, `.foo .baz .bar.bang`, `.foo .baz .bang .bar`,
247
- # and so on until `.baz .bang .foo .bar`.
248
- #
249
- # Semantically, for selectors A and B, this returns all selectors `AB_i`
250
- # such that the union over all i of elements matched by `AB_i X` is
251
- # identical to the intersection of all elements matched by `A X` and all
252
- # elements matched by `B X`. Some `AB_i` are elided to reduce the size of
253
- # the output.
254
- #
255
- # @param seq1 [Array<SimpleSequence or String>]
256
- # @param seq2 [Array<SimpleSequence or String>]
257
- # @return [Array<Array<SimpleSequence or String>>]
258
- def subweave(seq1, seq2)
259
- return [seq2] if seq1.empty?
260
- return [seq1] if seq2.empty?
261
-
262
- seq1, seq2 = seq1.dup, seq2.dup
263
- return unless (init = merge_initial_ops(seq1, seq2))
264
- return unless (fin = merge_final_ops(seq1, seq2))
265
-
266
- # Make sure there's only one root selector in the output.
267
- root1 = has_root?(seq1.first) && seq1.shift
268
- root2 = has_root?(seq2.first) && seq2.shift
269
- if root1 && root2
270
- return unless (root = root1.unify(root2))
271
- seq1.unshift root
272
- seq2.unshift root
273
- elsif root1
274
- seq2.unshift root1
275
- elsif root2
276
- seq1.unshift root2
277
- end
278
-
279
- seq1 = group_selectors(seq1)
280
- seq2 = group_selectors(seq2)
281
- lcs = Sass::Util.lcs(seq2, seq1) do |s1, s2|
282
- next s1 if s1 == s2
283
- next unless s1.first.is_a?(SimpleSequence) && s2.first.is_a?(SimpleSequence)
284
- next s2 if parent_superselector?(s1, s2)
285
- next s1 if parent_superselector?(s2, s1)
286
- end
287
-
288
- diff = [[init]]
289
-
290
- until lcs.empty?
291
- diff << chunks(seq1, seq2) {|s| parent_superselector?(s.first, lcs.first)} << [lcs.shift]
292
- seq1.shift
293
- seq2.shift
294
- end
295
- diff << chunks(seq1, seq2) {|s| s.empty?}
296
- diff += fin.map {|sel| sel.is_a?(Array) ? sel : [sel]}
297
- diff.reject! {|c| c.empty?}
298
-
299
- Sass::Util.paths(diff).map {|p| p.flatten}.reject {|p| path_has_two_subjects?(p)}
300
- end
301
-
302
- # Extracts initial selector combinators (`"+"`, `">"`, `"~"`, and `"\n"`)
303
- # from two sequences and merges them together into a single array of
304
- # selector combinators.
305
- #
306
- # @param seq1 [Array<SimpleSequence or String>]
307
- # @param seq2 [Array<SimpleSequence or String>]
308
- # @return [Array<String>, nil] If there are no operators in the merged
309
- # sequence, this will be the empty array. If the operators cannot be
310
- # merged, this will be nil.
311
- def merge_initial_ops(seq1, seq2)
312
- ops1, ops2 = [], []
313
- ops1 << seq1.shift while seq1.first.is_a?(String)
314
- ops2 << seq2.shift while seq2.first.is_a?(String)
315
-
316
- newline = false
317
- newline ||= !!ops1.shift if ops1.first == "\n"
318
- newline ||= !!ops2.shift if ops2.first == "\n"
319
-
320
- # If neither sequence is a subsequence of the other, they cannot be
321
- # merged successfully
322
- lcs = Sass::Util.lcs(ops1, ops2)
323
- return unless lcs == ops1 || lcs == ops2
324
- (newline ? ["\n"] : []) + (ops1.size > ops2.size ? ops1 : ops2)
325
- end
326
-
327
- # Extracts final selector combinators (`"+"`, `">"`, `"~"`) and the
328
- # selectors to which they apply from two sequences and merges them
329
- # together into a single array.
330
- #
331
- # @param seq1 [Array<SimpleSequence or String>]
332
- # @param seq2 [Array<SimpleSequence or String>]
333
- # @return [Array<SimpleSequence or String or
334
- # Array<Array<SimpleSequence or String>>]
335
- # If there are no trailing combinators to be merged, this will be the
336
- # empty array. If the trailing combinators cannot be merged, this will
337
- # be nil. Otherwise, this will contained the merged selector. Array
338
- # elements are [Sass::Util#paths]-style options; conceptually, an "or"
339
- # of multiple selectors.
340
- # @comment
341
- # rubocop:disable MethodLength
342
- def merge_final_ops(seq1, seq2, res = [])
343
- ops1, ops2 = [], []
344
- ops1 << seq1.pop while seq1.last.is_a?(String)
345
- ops2 << seq2.pop while seq2.last.is_a?(String)
346
-
347
- # Not worth the headache of trying to preserve newlines here. The most
348
- # important use of newlines is at the beginning of the selector to wrap
349
- # across lines anyway.
350
- ops1.reject! {|o| o == "\n"}
351
- ops2.reject! {|o| o == "\n"}
352
-
353
- return res if ops1.empty? && ops2.empty?
354
- if ops1.size > 1 || ops2.size > 1
355
- # If there are multiple operators, something hacky's going on. If one
356
- # is a supersequence of the other, use that, otherwise give up.
357
- lcs = Sass::Util.lcs(ops1, ops2)
358
- return unless lcs == ops1 || lcs == ops2
359
- res.unshift(*(ops1.size > ops2.size ? ops1 : ops2).reverse)
360
- return res
361
- end
362
-
363
- # This code looks complicated, but it's actually just a bunch of special
364
- # cases for interactions between different combinators.
365
- op1, op2 = ops1.first, ops2.first
366
- if op1 && op2
367
- sel1 = seq1.pop
368
- sel2 = seq2.pop
369
- if op1 == '~' && op2 == '~'
370
- if sel1.superselector?(sel2)
371
- res.unshift sel2, '~'
372
- elsif sel2.superselector?(sel1)
373
- res.unshift sel1, '~'
374
- else
375
- merged = sel1.unify(sel2)
376
- res.unshift [
377
- [sel1, '~', sel2, '~'],
378
- [sel2, '~', sel1, '~'],
379
- ([merged, '~'] if merged)
380
- ].compact
381
- end
382
- elsif (op1 == '~' && op2 == '+') || (op1 == '+' && op2 == '~')
383
- if op1 == '~'
384
- tilde_sel, plus_sel = sel1, sel2
385
- else
386
- tilde_sel, plus_sel = sel2, sel1
387
- end
388
-
389
- if tilde_sel.superselector?(plus_sel)
390
- res.unshift plus_sel, '+'
391
- else
392
- merged = plus_sel.unify(tilde_sel)
393
- res.unshift [
394
- [tilde_sel, '~', plus_sel, '+'],
395
- ([merged, '+'] if merged)
396
- ].compact
397
- end
398
- elsif op1 == '>' && %w(~ +).include?(op2)
399
- res.unshift sel2, op2
400
- seq1.push sel1, op1
401
- elsif op2 == '>' && %w(~ +).include?(op1)
402
- res.unshift sel1, op1
403
- seq2.push sel2, op2
404
- elsif op1 == op2
405
- merged = sel1.unify(sel2)
406
- return unless merged
407
- res.unshift merged, op1
408
- else
409
- # Unknown selector combinators can't be unified
410
- return
411
- end
412
- return merge_final_ops(seq1, seq2, res)
413
- elsif op1
414
- seq2.pop if op1 == '>' && seq2.last && seq2.last.superselector?(seq1.last)
415
- res.unshift seq1.pop, op1
416
- return merge_final_ops(seq1, seq2, res)
417
- else # op2
418
- seq1.pop if op2 == '>' && seq1.last && seq1.last.superselector?(seq2.last)
419
- res.unshift seq2.pop, op2
420
- return merge_final_ops(seq1, seq2, res)
421
- end
422
- end
423
- # @comment
424
- # rubocop:enable MethodLength
425
-
426
- # Takes initial subsequences of `seq1` and `seq2` and returns all
427
- # orderings of those subsequences. The initial subsequences are determined
428
- # by a block.
429
- #
430
- # Destructively removes the initial subsequences of `seq1` and `seq2`.
431
- #
432
- # For example, given `(A B C | D E)` and `(1 2 | 3 4 5)` (with `|`
433
- # denoting the boundary of the initial subsequence), this would return
434
- # `[(A B C 1 2), (1 2 A B C)]`. The sequences would then be `(D E)` and
435
- # `(3 4 5)`.
436
- #
437
- # @param seq1 [Array]
438
- # @param seq2 [Array]
439
- # @yield [a] Used to determine when to cut off the initial subsequences.
440
- # Called repeatedly for each sequence until it returns true.
441
- # @yieldparam a [Array] A final subsequence of one input sequence after
442
- # cutting off some initial subsequence.
443
- # @yieldreturn [Boolean] Whether or not to cut off the initial subsequence
444
- # here.
445
- # @return [Array<Array>] All possible orderings of the initial subsequences.
446
- def chunks(seq1, seq2)
447
- chunk1 = []
448
- chunk1 << seq1.shift until yield seq1
449
- chunk2 = []
450
- chunk2 << seq2.shift until yield seq2
451
- return [] if chunk1.empty? && chunk2.empty?
452
- return [chunk2] if chunk1.empty?
453
- return [chunk1] if chunk2.empty?
454
- [chunk1 + chunk2, chunk2 + chunk1]
455
- end
456
-
457
- # Groups a sequence into subsequences. The subsequences are determined by
458
- # strings; adjacent non-string elements will be put into separate groups,
459
- # but any element adjacent to a string will be grouped with that string.
460
- #
461
- # For example, `(A B "C" D E "F" G "H" "I" J)` will become `[(A) (B "C" D)
462
- # (E "F" G "H" "I" J)]`.
463
- #
464
- # @param seq [Array]
465
- # @return [Array<Array>]
466
- def group_selectors(seq)
467
- newseq = []
468
- tail = seq.dup
469
- until tail.empty?
470
- head = []
471
- begin
472
- head << tail.shift
473
- end while !tail.empty? && head.last.is_a?(String) || tail.first.is_a?(String)
474
- newseq << head
475
- end
476
- newseq
477
- end
478
-
479
- # Given two selector sequences, returns whether `seq1` is a
480
- # superselector of `seq2`; that is, whether `seq1` matches every
481
- # element `seq2` matches.
482
- #
483
- # @param seq1 [Array<SimpleSequence or String>]
484
- # @param seq2 [Array<SimpleSequence or String>]
485
- # @return [Boolean]
486
- def _superselector?(seq1, seq2)
487
- seq1 = seq1.reject {|e| e == "\n"}
488
- seq2 = seq2.reject {|e| e == "\n"}
489
- # Selectors with leading or trailing operators are neither
490
- # superselectors nor subselectors.
491
- return if seq1.last.is_a?(String) || seq2.last.is_a?(String) ||
492
- seq1.first.is_a?(String) || seq2.first.is_a?(String)
493
- # More complex selectors are never superselectors of less complex ones
494
- return if seq1.size > seq2.size
495
- return seq1.first.superselector?(seq2.last, seq2[0...-1]) if seq1.size == 1
496
-
497
- _, si = Sass::Util.enum_with_index(seq2).find do |e, i|
498
- return if i == seq2.size - 1
499
- next if e.is_a?(String)
500
- seq1.first.superselector?(e, seq2[0...i])
501
- end
502
- return unless si
503
-
504
- if seq1[1].is_a?(String)
505
- return unless seq2[si + 1].is_a?(String)
506
-
507
- # .foo ~ .bar is a superselector of .foo + .bar
508
- return unless seq1[1] == "~" ? seq2[si + 1] != ">" : seq1[1] == seq2[si + 1]
509
-
510
- # .foo > .baz is not a superselector of .foo > .bar > .baz or .foo >
511
- # .bar .baz, despite the fact that .baz is a superselector of .bar >
512
- # .baz and .bar .baz. Same goes for + and ~.
513
- return if seq1.length == 3 && seq2.length > 3
514
-
515
- return _superselector?(seq1[2..-1], seq2[si + 2..-1])
516
- elsif seq2[si + 1].is_a?(String)
517
- return unless seq2[si + 1] == ">"
518
- return _superselector?(seq1[1..-1], seq2[si + 2..-1])
519
- else
520
- return _superselector?(seq1[1..-1], seq2[si + 1..-1])
521
- end
522
- end
523
-
524
- # Like \{#_superselector?}, but compares the selectors in the
525
- # context of parent selectors, as though they shared an implicit
526
- # base simple selector. For example, `B` is not normally a
527
- # superselector of `B A`, since it doesn't match `A` elements.
528
- # However, it is a parent superselector, since `B X` is a
529
- # superselector of `B A X`.
530
- #
531
- # @param seq1 [Array<SimpleSequence or String>]
532
- # @param seq2 [Array<SimpleSequence or String>]
533
- # @return [Boolean]
534
- def parent_superselector?(seq1, seq2)
535
- base = Sass::Selector::SimpleSequence.new([Sass::Selector::Placeholder.new('<temp>')],
536
- false)
537
- _superselector?(seq1 + [base], seq2 + [base])
538
- end
539
-
540
- # Removes redundant selectors from between multiple lists of
541
- # selectors. This takes a list of lists of selector sequences;
542
- # each individual list is assumed to have no redundancy within
543
- # itself. A selector is only removed if it's redundant with a
544
- # selector in another list.
545
- #
546
- # "Redundant" here means that one selector is a superselector of
547
- # the other. The more specific selector is removed.
548
- #
549
- # @param seqses [Array<Array<Array<SimpleSequence or String>>>]
550
- # @return [Array<Array<SimpleSequence or String>>]
551
- def trim(seqses)
552
- # Avoid truly horrific quadratic behavior. TODO: I think there
553
- # may be a way to get perfect trimming without going quadratic.
554
- return seqses.flatten(1) if seqses.size > 100
555
-
556
- # Keep the results in a separate array so we can be sure we aren't
557
- # comparing against an already-trimmed selector. This ensures that two
558
- # identical selectors don't mutually trim one another.
559
- result = seqses.dup
560
-
561
- # This is n^2 on the sequences, but only comparing between
562
- # separate sequences should limit the quadratic behavior.
563
- seqses.each_with_index do |seqs1, i|
564
- result[i] = seqs1.reject do |seq1|
565
- # The maximum specificity of the sources that caused [seq1] to be
566
- # generated. In order for [seq1] to be removed, there must be
567
- # another selector that's a superselector of it *and* that has
568
- # specificity greater or equal to this.
569
- max_spec = _sources(seq1).map do |seq|
570
- spec = seq.specificity
571
- spec.is_a?(Range) ? spec.max : spec
572
- end.max || 0
573
-
574
- result.any? do |seqs2|
575
- next if seqs1.equal?(seqs2)
576
- # Second Law of Extend: the specificity of a generated selector
577
- # should never be less than the specificity of the extending
578
- # selector.
579
- #
580
- # See https://github.com/nex3/sass/issues/324.
581
- seqs2.any? do |seq2|
582
- spec2 = _specificity(seq2)
583
- spec2 = spec2.begin if spec2.is_a?(Range)
584
- spec2 >= max_spec && _superselector?(seq2, seq1)
585
- end
586
- end
587
- end
588
- end
589
- result.flatten(1)
590
- end
591
-
592
- def _hash
593
- members.reject {|m| m == "\n"}.hash
594
- end
595
-
596
- def _eql?(other)
597
- other.members.reject {|m| m == "\n"}.eql?(members.reject {|m| m == "\n"})
598
- end
599
-
600
- private
601
-
602
- def path_has_two_subjects?(path)
603
- subject = false
604
- path.each do |sseq_or_op|
605
- next unless sseq_or_op.is_a?(SimpleSequence)
606
- next unless sseq_or_op.subject?
607
- return true if subject
608
- subject = true
609
- end
610
- false
611
- end
612
-
613
- def _sources(seq)
614
- s = Set.new
615
- seq.map {|sseq_or_op| s.merge sseq_or_op.sources if sseq_or_op.is_a?(SimpleSequence)}
616
- s
617
- end
618
-
619
- def extended_not_expanded_to_s(extended_not_expanded)
620
- extended_not_expanded.map do |choices|
621
- choices = choices.map do |sel|
622
- next sel.first.to_s if sel.size == 1
623
- "#{sel.join ' '}"
624
- end
625
- next choices.first if choices.size == 1 && !choices.include?(' ')
626
- "(#{choices.join ', '})"
627
- end.join ' '
628
- end
629
-
630
- def has_root?(sseq)
631
- sseq.is_a?(SimpleSequence) &&
632
- sseq.members.any? {|sel| sel.is_a?(Pseudo) && sel.normalized_name == "root"}
633
- end
634
- end
635
- end
636
- end