brakeman 5.2.1 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +21 -0
  3. data/bundle/load.rb +4 -4
  4. data/bundle/ruby/2.7.0/gems/{parallel-1.21.0 → parallel-1.22.1}/MIT-LICENSE.txt +0 -0
  5. data/bundle/ruby/2.7.0/gems/{parallel-1.21.0 → parallel-1.22.1}/lib/parallel/processor_count.rb +2 -3
  6. data/bundle/ruby/2.7.0/gems/parallel-1.22.1/lib/parallel/version.rb +4 -0
  7. data/bundle/ruby/2.7.0/gems/{parallel-1.21.0 → parallel-1.22.1}/lib/parallel.rb +84 -4
  8. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/History.rdoc +28 -0
  9. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/Manifest.txt +2 -0
  10. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/README.rdoc +8 -6
  11. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/compare/normalize.rb +0 -0
  12. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/debugging.md +0 -0
  13. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/gauntlet.md +19 -18
  14. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/rp_extensions.rb +0 -0
  15. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/rp_stringscanner.rb +0 -0
  16. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby20_parser.rb +10973 -0
  17. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby20_parser.y +14 -27
  18. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby21_parser.rb +10980 -0
  19. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby21_parser.y +14 -27
  20. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby22_parser.rb +11123 -0
  21. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby22_parser.y +14 -27
  22. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby23_parser.rb +11132 -0
  23. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby23_parser.y +14 -27
  24. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby24_parser.rb +11231 -0
  25. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby24_parser.y +14 -27
  26. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby25_parser.rb +11231 -0
  27. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby25_parser.y +14 -27
  28. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby26_parser.rb +11253 -0
  29. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby26_parser.y +14 -27
  30. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby27_parser.rb +12980 -0
  31. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby27_parser.y +19 -41
  32. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby30_parser.rb +13242 -0
  33. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby30_parser.y +65 -90
  34. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby31_parser.rb +13622 -0
  35. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1/lib/ruby3_parser.yy → ruby_parser-3.19.1/lib/ruby31_parser.y} +110 -105
  36. data/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby3_parser.yy +3536 -0
  37. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby_lexer.rb +0 -0
  38. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby_lexer.rex +0 -0
  39. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby_lexer.rex.rb +0 -0
  40. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby_lexer_strings.rb +0 -0
  41. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby_parser.rb +2 -0
  42. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby_parser.yy +19 -41
  43. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/lib/ruby_parser_extras.rb +55 -2
  44. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/tools/munge.rb +0 -0
  45. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.18.1 → ruby_parser-3.19.1}/tools/ripper.rb +0 -0
  46. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/History.rdoc +6 -0
  47. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/Manifest.txt +0 -0
  48. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/README.rdoc +0 -0
  49. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/lib/composite_sexp_processor.rb +0 -0
  50. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/lib/pt_testcase.rb +7 -3
  51. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/lib/sexp.rb +0 -0
  52. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/lib/sexp_matcher.rb +0 -0
  53. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/lib/sexp_processor.rb +1 -1
  54. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/lib/strict_sexp.rb +0 -0
  55. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.16.0 → sexp_processor-4.16.1}/lib/unique.rb +0 -0
  56. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/COPYING +0 -0
  57. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/asciidoc.rb +0 -0
  58. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/babel.rb +0 -0
  59. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/bluecloth.rb +0 -0
  60. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/builder.rb +0 -0
  61. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/coffee.rb +0 -0
  62. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/commonmarker.rb +11 -1
  63. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/creole.rb +0 -0
  64. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/csv.rb +1 -1
  65. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/dummy.rb +0 -0
  66. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/erb.rb +0 -0
  67. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/erubi.rb +0 -0
  68. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/erubis.rb +0 -0
  69. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/etanni.rb +0 -0
  70. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/haml.rb +0 -0
  71. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/kramdown.rb +0 -0
  72. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/less.rb +0 -0
  73. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/liquid.rb +0 -0
  74. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/livescript.rb +0 -0
  75. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/mapping.rb +0 -0
  76. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/markaby.rb +0 -0
  77. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/maruku.rb +0 -0
  78. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/nokogiri.rb +0 -0
  79. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/pandoc.rb +23 -15
  80. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/plain.rb +0 -0
  81. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/prawn.rb +0 -0
  82. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/radius.rb +0 -0
  83. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/rdiscount.rb +0 -0
  84. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/rdoc.rb +0 -0
  85. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/redcarpet.rb +5 -2
  86. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/redcloth.rb +0 -0
  87. data/bundle/ruby/2.7.0/gems/tilt-2.0.11/lib/tilt/rst-pandoc.rb +23 -0
  88. data/bundle/ruby/2.7.0/gems/tilt-2.0.11/lib/tilt/sass.rb +78 -0
  89. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/sigil.rb +0 -0
  90. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/string.rb +0 -0
  91. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/template.rb +12 -1
  92. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/typescript.rb +0 -0
  93. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/wikicloth.rb +0 -0
  94. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt/yajl.rb +0 -0
  95. data/bundle/ruby/2.7.0/gems/{tilt-2.0.10 → tilt-2.0.11}/lib/tilt.rb +2 -1
  96. data/lib/brakeman/app_tree.rb +9 -1
  97. data/lib/brakeman/checks/check_basic_auth.rb +4 -2
  98. data/lib/brakeman/checks/check_basic_auth_timing_attack.rb +2 -1
  99. data/lib/brakeman/checks/check_content_tag.rb +8 -4
  100. data/lib/brakeman/checks/check_cookie_serialization.rb +2 -1
  101. data/lib/brakeman/checks/check_create_with.rb +4 -2
  102. data/lib/brakeman/checks/check_cross_site_scripting.rb +6 -3
  103. data/lib/brakeman/checks/check_csrf_token_forgery_cve.rb +2 -1
  104. data/lib/brakeman/checks/check_default_routes.rb +6 -3
  105. data/lib/brakeman/checks/check_deserialize.rb +2 -1
  106. data/lib/brakeman/checks/check_detailed_exceptions.rb +4 -2
  107. data/lib/brakeman/checks/check_digest_dos.rb +2 -1
  108. data/lib/brakeman/checks/check_divide_by_zero.rb +2 -1
  109. data/lib/brakeman/checks/check_dynamic_finders.rb +2 -1
  110. data/lib/brakeman/checks/check_escape_function.rb +2 -1
  111. data/lib/brakeman/checks/check_evaluation.rb +2 -1
  112. data/lib/brakeman/checks/check_execute.rb +6 -3
  113. data/lib/brakeman/checks/check_file_access.rb +2 -1
  114. data/lib/brakeman/checks/check_file_disclosure.rb +2 -1
  115. data/lib/brakeman/checks/check_filter_skipping.rb +2 -1
  116. data/lib/brakeman/checks/check_force_ssl.rb +2 -1
  117. data/lib/brakeman/checks/check_forgery_setting.rb +4 -2
  118. data/lib/brakeman/checks/check_header_dos.rb +2 -1
  119. data/lib/brakeman/checks/check_i18n_xss.rb +2 -1
  120. data/lib/brakeman/checks/check_jruby_xml.rb +2 -1
  121. data/lib/brakeman/checks/check_json_encoding.rb +2 -1
  122. data/lib/brakeman/checks/check_json_entity_escape.rb +4 -2
  123. data/lib/brakeman/checks/check_json_parsing.rb +4 -2
  124. data/lib/brakeman/checks/check_link_to.rb +2 -1
  125. data/lib/brakeman/checks/check_link_to_href.rb +4 -2
  126. data/lib/brakeman/checks/check_mail_to.rb +2 -1
  127. data/lib/brakeman/checks/check_mass_assignment.rb +6 -3
  128. data/lib/brakeman/checks/check_mime_type_dos.rb +2 -1
  129. data/lib/brakeman/checks/check_model_attr_accessible.rb +2 -1
  130. data/lib/brakeman/checks/check_model_attributes.rb +4 -2
  131. data/lib/brakeman/checks/check_model_serialize.rb +2 -1
  132. data/lib/brakeman/checks/check_nested_attributes.rb +2 -1
  133. data/lib/brakeman/checks/check_nested_attributes_bypass.rb +2 -1
  134. data/lib/brakeman/checks/check_number_to_currency.rb +4 -2
  135. data/lib/brakeman/checks/check_page_caching_cve.rb +2 -1
  136. data/lib/brakeman/checks/check_permit_attributes.rb +2 -1
  137. data/lib/brakeman/checks/check_quote_table_name.rb +2 -1
  138. data/lib/brakeman/checks/check_redirect.rb +2 -1
  139. data/lib/brakeman/checks/check_regex_dos.rb +2 -1
  140. data/lib/brakeman/checks/check_render.rb +4 -2
  141. data/lib/brakeman/checks/check_render_dos.rb +2 -1
  142. data/lib/brakeman/checks/check_render_inline.rb +4 -2
  143. data/lib/brakeman/checks/check_response_splitting.rb +2 -1
  144. data/lib/brakeman/checks/check_reverse_tabnabbing.rb +2 -1
  145. data/lib/brakeman/checks/check_route_dos.rb +2 -1
  146. data/lib/brakeman/checks/check_safe_buffer_manipulation.rb +2 -1
  147. data/lib/brakeman/checks/check_sanitize_config_cve.rb +120 -0
  148. data/lib/brakeman/checks/check_sanitize_methods.rb +6 -3
  149. data/lib/brakeman/checks/check_secrets.rb +2 -1
  150. data/lib/brakeman/checks/check_select_tag.rb +2 -1
  151. data/lib/brakeman/checks/check_select_vulnerability.rb +2 -1
  152. data/lib/brakeman/checks/check_send.rb +2 -1
  153. data/lib/brakeman/checks/check_session_manipulation.rb +2 -1
  154. data/lib/brakeman/checks/check_session_settings.rb +6 -3
  155. data/lib/brakeman/checks/check_simple_format.rb +4 -2
  156. data/lib/brakeman/checks/check_single_quotes.rb +2 -1
  157. data/lib/brakeman/checks/check_skip_before_filter.rb +4 -2
  158. data/lib/brakeman/checks/check_sprockets_path_traversal.rb +2 -1
  159. data/lib/brakeman/checks/check_sql.rb +7 -4
  160. data/lib/brakeman/checks/check_sql_cves.rb +4 -2
  161. data/lib/brakeman/checks/check_ssl_verify.rb +2 -1
  162. data/lib/brakeman/checks/check_strip_tags.rb +6 -3
  163. data/lib/brakeman/checks/check_symbol_dos.rb +2 -1
  164. data/lib/brakeman/checks/check_symbol_dos_cve.rb +2 -1
  165. data/lib/brakeman/checks/check_template_injection.rb +2 -1
  166. data/lib/brakeman/checks/check_translate_bug.rb +2 -1
  167. data/lib/brakeman/checks/check_unsafe_reflection.rb +9 -3
  168. data/lib/brakeman/checks/check_unsafe_reflection_methods.rb +2 -1
  169. data/lib/brakeman/checks/check_unscoped_find.rb +2 -1
  170. data/lib/brakeman/checks/check_validation_regex.rb +2 -1
  171. data/lib/brakeman/checks/check_verb_confusion.rb +2 -1
  172. data/lib/brakeman/checks/check_weak_hash.rb +6 -3
  173. data/lib/brakeman/checks/check_without_protection.rb +2 -1
  174. data/lib/brakeman/checks/check_xml_dos.rb +2 -1
  175. data/lib/brakeman/checks/check_yaml_parsing.rb +4 -2
  176. data/lib/brakeman/checks/eol_check.rb +4 -2
  177. data/lib/brakeman/options.rb +1 -1
  178. data/lib/brakeman/processors/alias_processor.rb +41 -2
  179. data/lib/brakeman/processors/lib/find_all_calls.rb +1 -0
  180. data/lib/brakeman/report/ignore/interactive.rb +2 -2
  181. data/lib/brakeman/report/report_csv.rb +2 -0
  182. data/lib/brakeman/report/report_junit.rb +2 -2
  183. data/lib/brakeman/report/report_table.rb +5 -5
  184. data/lib/brakeman/report/report_text.rb +2 -0
  185. data/lib/brakeman/report/templates/controller_warnings.html.erb +2 -0
  186. data/lib/brakeman/report/templates/ignored_warnings.html.erb +2 -0
  187. data/lib/brakeman/report/templates/model_warnings.html.erb +2 -0
  188. data/lib/brakeman/report/templates/security_warnings.html.erb +2 -0
  189. data/lib/brakeman/report/templates/view_warnings.html.erb +2 -0
  190. data/lib/brakeman/version.rb +1 -1
  191. data/lib/brakeman/warning.rb +5 -2
  192. data/lib/brakeman/warning_codes.rb +1 -0
  193. metadata +95 -92
  194. data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel/version.rb +0 -4
  195. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby20_parser.rb +0 -7128
  196. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby21_parser.rb +0 -7182
  197. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby22_parser.rb +0 -7228
  198. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby23_parser.rb +0 -7237
  199. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby24_parser.rb +0 -7268
  200. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby25_parser.rb +0 -7268
  201. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby26_parser.rb +0 -7287
  202. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby27_parser.rb +0 -8517
  203. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby30_parser.rb +0 -8751
  204. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/rst-pandoc.rb +0 -18
  205. data/bundle/ruby/2.7.0/gems/tilt-2.0.10/lib/tilt/sass.rb +0 -52
@@ -80,10 +80,12 @@ require "ruby25_parser"
80
80
  require "ruby26_parser"
81
81
  require "ruby27_parser"
82
82
  require "ruby30_parser"
83
+ require "ruby31_parser"
83
84
 
84
85
  class RubyParser # HACK
85
86
  VERSIONS.clear # also a HACK caused by racc namespace issues
86
87
 
88
+ class V31 < ::Ruby31Parser; end
87
89
  class V30 < ::Ruby30Parser; end
88
90
  class V27 < ::Ruby27Parser; end
89
91
  class V26 < ::Ruby26Parser; end
@@ -767,8 +767,7 @@ rule
767
767
 
768
768
  cpath: tCOLON3 cname
769
769
  {
770
- _, (name, line) = val
771
- result = s(:colon3, name.to_sym).line line
770
+ result = wrap :colon3, val[1]
772
771
  }
773
772
  | cname
774
773
  {
@@ -793,9 +792,7 @@ rule
793
792
 
794
793
  fitem: fname
795
794
  {
796
- (id, line), = val
797
-
798
- result = s(:lit, id.to_sym).line line
795
+ result = wrap :lit, val[0]
799
796
  }
800
797
  | symbol
801
798
 
@@ -864,9 +861,9 @@ rule
864
861
  }
865
862
  | tCOLON3 tCONSTANT tOP_ASGN arg_rhs
866
863
  {
867
- _, (lhs, line), op, rhs = val
864
+ _, lhs, op, rhs = val
868
865
 
869
- lhs = s(:colon3, lhs.to_sym).line line
866
+ lhs = wrap :colon3, lhs
870
867
  result = new_const_op_asgn [lhs, op, rhs]
871
868
  }
872
869
  | backref tOP_ASGN arg_rhs
@@ -1336,9 +1333,7 @@ rule
1336
1333
  }
1337
1334
  | tCOLON3 tCONSTANT
1338
1335
  {
1339
- _, (id, line) = val
1340
-
1341
- result = s(:colon3, id.to_sym).line line
1336
+ result = wrap :colon3, val[1]
1342
1337
  }
1343
1338
  | tLBRACK { result = lexer.lineno } aref_args tRBRACK
1344
1339
  {
@@ -1846,8 +1841,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1846
1841
 
1847
1842
  bvar: tIDENTIFIER
1848
1843
  {
1849
- (id, line), = val
1850
- result = s(:shadow, id.to_sym).line line
1844
+ result = wrap :shadow, val[0]
1851
1845
  }
1852
1846
  | f_bad_arg
1853
1847
 
@@ -2458,9 +2452,7 @@ opt_block_args_tail: tCOMMA block_args_tail
2458
2452
 
2459
2453
  p_kw_label: tLABEL
2460
2454
  {
2461
- (id, line), = val
2462
-
2463
- result = s(:lit, id.to_sym).line line
2455
+ result = wrap :lit, val[0]
2464
2456
  }
2465
2457
 
2466
2458
  p_kwrest: kwrest_mark tIDENTIFIER
@@ -2552,26 +2544,20 @@ opt_block_args_tail: tCOMMA block_args_tail
2552
2544
 
2553
2545
  p_variable: tIDENTIFIER
2554
2546
  {
2555
- (id, line), = val
2556
-
2557
2547
  # TODO: error_duplicate_pattern_variable(p, $1, &@1);
2558
2548
  # TODO: assignable(p, $1, 0, &@$);
2559
- result = s(:lvar, id.to_sym).line line
2549
+ result = wrap :lvar, val[0]
2560
2550
  }
2561
2551
 
2562
2552
  p_var_ref: tCARET tIDENTIFIER
2563
2553
  {
2564
- _, (id, line) = val
2565
-
2566
2554
  # TODO: check id against env for lvar or dvar
2567
-
2568
- result = s(:lvar, id.to_sym).line line
2555
+ result = wrap :lvar, val[1]
2569
2556
  }
2570
2557
 
2571
2558
  p_const: tCOLON3 cname
2572
2559
  {
2573
- _, (id, line) = val
2574
- result = s(:colon3, id.to_sym).line line
2560
+ result = wrap :colon3, val[1]
2575
2561
  }
2576
2562
  | p_const tCOLON2 cname
2577
2563
  {
@@ -2583,8 +2569,7 @@ opt_block_args_tail: tCOMMA block_args_tail
2583
2569
  | tCONSTANT
2584
2570
  {
2585
2571
  # TODO $$ = gettable(p, $1, &@$);
2586
- (id, line), = val
2587
- result = s(:const, id.to_sym).line line
2572
+ result = wrap :const, val[0]
2588
2573
  }
2589
2574
  ######################################################################
2590
2575
  #endif
@@ -2871,18 +2856,15 @@ regexp_contents: none
2871
2856
 
2872
2857
  string_dvar: tGVAR
2873
2858
  {
2874
- (id, line), = val
2875
- result = s(:gvar, id.to_sym).line line
2859
+ result = wrap :gvar, val[0]
2876
2860
  }
2877
2861
  | tIVAR
2878
2862
  {
2879
- (id, line), = val
2880
- result = s(:ivar, id.to_sym).line line
2863
+ result = wrap :ivar, val[0]
2881
2864
  }
2882
2865
  | tCVAR
2883
2866
  {
2884
- (id, line), = val
2885
- result = s(:cvar, id.to_sym).line line
2867
+ result = wrap :cvar, val[0]
2886
2868
  }
2887
2869
  | backref
2888
2870
 
@@ -2891,17 +2873,13 @@ regexp_contents: none
2891
2873
 
2892
2874
  ssym: tSYMBEG sym
2893
2875
  {
2894
- _, (id, line) = val
2895
-
2896
2876
  lexer.lex_state = EXPR_END
2897
- result = s(:lit, id.to_sym).line line
2877
+ result = wrap :lit, val[1]
2898
2878
  }
2899
2879
  | tSYMBOL
2900
2880
  {
2901
- (id, line), = val
2902
-
2903
2881
  lexer.lex_state = EXPR_END
2904
- result = s(:lit, id.to_sym).line line
2882
+ result = wrap :lit, val[0]
2905
2883
  }
2906
2884
 
2907
2885
  sym: fname | tIVAR | tGVAR | tCVAR
@@ -3422,10 +3400,10 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
3422
3400
  }
3423
3401
  | tLABEL arg_value
3424
3402
  {
3425
- (label, line), arg = val
3403
+ label, arg = val
3426
3404
 
3427
- lit = s(:lit, label.to_sym).line line
3428
- result = s(:array, lit, arg).line line
3405
+ lit = wrap :lit, label
3406
+ result = s(:array, lit, arg).line lit.line
3429
3407
  }
3430
3408
  #if V >= 22
3431
3409
  | tSTRING_BEG string_contents tLABEL_END arg_value
@@ -30,7 +30,7 @@ class Sexp
30
30
  end
31
31
 
32
32
  module RubyParserStuff
33
- VERSION = "3.18.1"
33
+ VERSION = "3.19.1"
34
34
 
35
35
  attr_accessor :lexer, :in_def, :in_single, :file
36
36
  attr_accessor :in_kwarg
@@ -218,11 +218,15 @@ module RubyParserStuff
218
218
  self.args args
219
219
  end
220
220
 
221
+ def attrset_id? id
222
+ id =~ /^\[\]=$|^\w+=$/
223
+ end
224
+
221
225
  def endless_method_name defn_or_defs
222
226
  name = defn_or_defs[1]
223
227
  name = defn_or_defs[2] unless Symbol === name
224
228
 
225
- if name.end_with? "=" then
229
+ if attrset_id? name then
226
230
  yyerror "setter method cannot be defined in an endless method definition"
227
231
  end
228
232
 
@@ -978,6 +982,49 @@ module RubyParserStuff
978
982
  [result, in_def]
979
983
  end
980
984
 
985
+ def new_endless_defn val
986
+ (name, line, in_def), args, _, body, _, resbody = val
987
+
988
+ result =
989
+ if resbody then
990
+ s(:defn, name, args,
991
+ new_rescue(body,
992
+ new_resbody(s(:array).line(line),
993
+ resbody))).line line
994
+ else
995
+ s(:defn, name, args, body).line line
996
+ end
997
+
998
+ local_pop in_def
999
+ endless_method_name result
1000
+
1001
+ result.comments = self.comments.pop
1002
+
1003
+ result
1004
+ end
1005
+
1006
+ def new_endless_defs val
1007
+ (recv, (name, line, in_def)), args, _, body, _, resbody = val
1008
+
1009
+ result =
1010
+ if resbody then
1011
+ s(:defs, recv, name, args,
1012
+ new_rescue(body,
1013
+ new_resbody(s(:array).line(line),
1014
+ resbody))).line line
1015
+ else
1016
+ s(:defs, recv, name, args, body).line(line)
1017
+ end
1018
+
1019
+ self.in_single -= 1
1020
+ local_pop in_def
1021
+ endless_method_name result
1022
+
1023
+ result.comments = self.comments.pop
1024
+
1025
+ result
1026
+ end
1027
+
981
1028
  def new_defs val
982
1029
  _, recv, (name, line), in_def, args, body, _ = val
983
1030
 
@@ -1613,6 +1660,12 @@ module RubyParserStuff
1613
1660
 
1614
1661
  alias remove_whitespace_width whitespace_width
1615
1662
 
1663
+ def wrap type, node
1664
+ value, line = node
1665
+ value = value.to_sym if value.respond_to? :to_sym
1666
+ s(type, value).line line
1667
+ end
1668
+
1616
1669
  class Keyword
1617
1670
  include RubyLexer::State::Values
1618
1671
 
@@ -1,3 +1,9 @@
1
+ === 4.16.1 / 2022-04-09
2
+
3
+ * 1 minor enhancement:
4
+
5
+ * Reworked ParseTreeTestCase's notion of versions to make it easier to extend.
6
+
1
7
  === 4.16.0 / 2021-10-27
2
8
 
3
9
  * 4 minor enhancements:
@@ -34,6 +34,12 @@ class Examples
34
34
  end
35
35
 
36
36
  class ParseTreeTestCase < Minitest::Test
37
+ all_versions = %w[18 19 20 21 22 23 24 25 26 27 30 31]
38
+ most_versions = all_versions.drop(1)
39
+
40
+ TEST_SUFFIX = "_#{most_versions.join "_"}"
41
+ VER_RE = /(#{Regexp.union(*all_versions)})/
42
+
37
43
  attr_accessor :processor # to be defined by subclass
38
44
 
39
45
  def setup
@@ -77,7 +83,7 @@ class ParseTreeTestCase < Minitest::Test
77
83
  end
78
84
 
79
85
  def self.add_19tests name, hash
80
- add_tests "#{name}__19_20_21_22_23_24_25_26_27_30", hash # HACK?
86
+ add_tests "#{name}_#{TEST_SUFFIX}", hash # HACK?
81
87
  end
82
88
 
83
89
  def self.add_19edgecases ruby, sexp, cases
@@ -102,8 +108,6 @@ class ParseTreeTestCase < Minitest::Test
102
108
  testcases[verbose][klass] = testcases[nonverbose][klass]
103
109
  end
104
110
 
105
- VER_RE = "(1[89]|2[01234567]|3[0])"
106
-
107
111
  def self.generate_test klass, node, data, input_name, output_name
108
112
  klass.send :define_method, "test_#{node}" do
109
113
  flunk "Processor is nil" if processor.nil?
@@ -34,7 +34,7 @@ require "sexp"
34
34
  class SexpProcessor
35
35
 
36
36
  # duh
37
- VERSION = "4.16.0"
37
+ VERSION = "4.16.1"
38
38
 
39
39
  ##
40
40
  # Automatically shifts off the Sexp type before handing the
@@ -9,21 +9,31 @@ module Tilt
9
9
  :smartypants => :SMART
10
10
  }
11
11
  PARSE_OPTIONS = [
12
+ :FOOTNOTES,
13
+ :LIBERAL_HTML_TAG,
12
14
  :SMART,
13
15
  :smartypants,
16
+ :STRIKETHROUGH_DOUBLE_TILDE,
17
+ :UNSAFE,
18
+ :VALIDATE_UTF8,
14
19
  ].freeze
15
20
  RENDER_OPTIONS = [
21
+ :FOOTNOTES,
22
+ :FULL_INFO_STRING,
16
23
  :GITHUB_PRE_LANG,
17
24
  :HARDBREAKS,
18
25
  :NOBREAKS,
19
- :SAFE,
26
+ :SAFE, # Removed in v0.18.0 (2018-10-17)
20
27
  :SOURCEPOS,
28
+ :TABLE_PREFER_STYLE_ATTRIBUTES,
29
+ :UNSAFE,
21
30
  ].freeze
22
31
  EXTENSIONS = [
23
32
  :autolink,
24
33
  :strikethrough,
25
34
  :table,
26
35
  :tagfilter,
36
+ :tasklist,
27
37
  ].freeze
28
38
 
29
39
  def extensions
@@ -50,7 +50,7 @@ module Tilt
50
50
 
51
51
  def precompiled_template(locals)
52
52
  <<-RUBY
53
- #{@outvar} = #{self.class.engine}.generate(#{options}) do |csv|
53
+ #{@outvar} = #{self.class.engine}.generate(**#{options}) do |csv|
54
54
  #{data}
55
55
  end
56
56
  RUBY
@@ -7,30 +7,38 @@ module Tilt
7
7
  class PandocTemplate < Template
8
8
  self.default_mime_type = 'text/html'
9
9
 
10
- def tilt_to_pandoc_mapping
11
- { :smartypants => :smart,
12
- :escape_html => { :f => 'markdown-raw_html' },
13
- :commonmark => { :f => 'commonmark' },
14
- :markdown_strict => { :f => 'markdown_strict' }
15
- }
16
- end
17
-
18
10
  # turn options hash into an array
19
11
  # Map tilt options to pandoc options
20
12
  # Replace hash keys with value true with symbol for key
21
13
  # Remove hash keys with value false
22
14
  # Leave other hash keys untouched
23
15
  def pandoc_options
24
- options.reduce([]) do |sum, (k,v)|
25
- case v
26
- when true
27
- sum << (tilt_to_pandoc_mapping[k] || k)
28
- when false
29
- sum
16
+ result = []
17
+ from = "markdown"
18
+ smart_extension = "-smart"
19
+ options.each do |k,v|
20
+ case k
21
+ when :smartypants
22
+ smart_extension = "+smart" if v
23
+ when :escape_html
24
+ from = "markdown-raw_html" if v
25
+ when :commonmark
26
+ from = "commonmark" if v
27
+ when :markdown_strict
28
+ from = "markdown_strict" if v
30
29
  else
31
- sum << { k => v }
30
+ case v
31
+ when true
32
+ result << k
33
+ when false
34
+ # do nothing
35
+ else
36
+ result << { k => v }
37
+ end
32
38
  end
33
39
  end
40
+ result << { :f => from + smart_extension }
41
+ result
34
42
  end
35
43
 
36
44
  def prepare
@@ -75,9 +75,12 @@ module Tilt
75
75
  end
76
76
 
77
77
  if defined? ::Redcarpet::Render and defined? ::Redcarpet::Markdown
78
- RedcarpetTemplate = Redcarpet2Template
78
+ superclass = Redcarpet2Template
79
79
  else
80
- RedcarpetTemplate = Redcarpet1Template
80
+ superclass = Redcarpet1Template
81
+ end
82
+
83
+ class RedcarpetTemplate < superclass
81
84
  end
82
85
  end
83
86
 
@@ -0,0 +1,23 @@
1
+ require 'tilt/template'
2
+ require 'pandoc'
3
+
4
+ module Tilt
5
+ # Pandoc reStructuredText implementation. See:
6
+ # http://pandoc.org/
7
+ class RstPandocTemplate < PandocTemplate
8
+ self.default_mime_type = 'text/html'
9
+
10
+ def prepare
11
+ @engine = PandocRuby.new(data, :f => "rst")
12
+ @output = nil
13
+ end
14
+
15
+ def evaluate(scope, locals, &block)
16
+ @output ||= @engine.to_html.strip
17
+ end
18
+
19
+ def allows_script?
20
+ false
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,78 @@
1
+ require 'tilt/template'
2
+
3
+ module Tilt
4
+ # Sass template implementation. See:
5
+ # http://haml.hamptoncatlin.com/
6
+ #
7
+ # Sass templates do not support object scopes, locals, or yield.
8
+ class SassTemplate < Template
9
+ self.default_mime_type = 'text/css'
10
+
11
+ begin
12
+ require 'sass-embedded'
13
+ require 'uri'
14
+ Engine = nil
15
+ rescue LoadError => err
16
+ begin
17
+ require 'sassc'
18
+ Engine = ::SassC::Engine
19
+ rescue LoadError
20
+ begin
21
+ require 'sass'
22
+ Engine = ::Sass::Engine
23
+ rescue LoadError
24
+ raise err
25
+ end
26
+ end
27
+ end
28
+
29
+ def prepare
30
+ @engine = unless Engine.nil?
31
+ Engine.new(data, sass_options)
32
+ end
33
+ end
34
+
35
+ def evaluate(scope, locals, &block)
36
+ @output ||= if @engine.nil?
37
+ ::Sass.compile_string(data, **sass_embedded_options).css
38
+ else
39
+ @engine.render
40
+ end
41
+ end
42
+
43
+ def allows_script?
44
+ false
45
+ end
46
+
47
+ private
48
+ def eval_file_url
49
+ path = File.absolute_path(eval_file)
50
+ path = '/' + path unless path.start_with?('/')
51
+ ::URI::File.build([nil, ::URI::DEFAULT_PARSER.escape(path)]).to_s
52
+ end
53
+
54
+ def sass_embedded_options
55
+ options.merge(:url => eval_file_url, :syntax => :indented)
56
+ end
57
+
58
+ def sass_options
59
+ options.merge(:filename => eval_file, :line => line, :syntax => :sass)
60
+ end
61
+ end
62
+
63
+ # Sass's new .scss type template implementation.
64
+ class ScssTemplate < SassTemplate
65
+ self.default_mime_type = 'text/css'
66
+
67
+ private
68
+ def sass_embedded_options
69
+ options.merge(:url => eval_file_url, :syntax => :scss)
70
+ end
71
+
72
+ def sass_options
73
+ options.merge(:filename => eval_file, :line => line, :syntax => :scss)
74
+ end
75
+ end
76
+
77
+ end
78
+
@@ -157,6 +157,8 @@ module Tilt
157
157
  raise NotImplementedError
158
158
  end
159
159
 
160
+ CLASS_METHOD = Kernel.instance_method(:class)
161
+
160
162
  # Execute the compiled template and return the result string. Template
161
163
  # evaluation is guaranteed to be performed in the scope object with the
162
164
  # locals specified and with support for yielding to the block.
@@ -166,7 +168,16 @@ module Tilt
166
168
  def evaluate(scope, locals, &block)
167
169
  locals_keys = locals.keys
168
170
  locals_keys.sort!{|x, y| x.to_s <=> y.to_s}
169
- method = compiled_method(locals_keys, scope.is_a?(Module) ? scope : scope.class)
171
+ case scope
172
+ when Object
173
+ method = compiled_method(locals_keys, Module === scope ? scope : scope.class)
174
+ else
175
+ if RUBY_VERSION >= '2'
176
+ method = compiled_method(locals_keys, CLASS_METHOD.bind(scope).call)
177
+ else
178
+ method = compiled_method(locals_keys, Object)
179
+ end
180
+ end
170
181
  method.bind(scope).call(locals, &block)
171
182
  end
172
183