brakeman 7.1.2 → 8.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +48 -0
  3. data/README.md +1 -1
  4. data/bundle/load.rb +7 -7
  5. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/NEWS.md +39 -1
  6. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/README.md +1 -1
  7. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv/parser.rb +7 -2
  8. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv/row.rb +26 -2
  9. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv/version.rb +1 -1
  10. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv.rb +30 -58
  11. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/CHANGELOG +111 -0
  12. data/bundle/ruby/3.2.0/gems/{erubis-2.7.0 → erubi-1.13.1}/MIT-LICENSE +1 -0
  13. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/README.rdoc +151 -0
  14. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/lib/erubi/capture_block.rb +91 -0
  15. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/lib/erubi/capture_end.rb +58 -0
  16. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/lib/erubi.rb +299 -0
  17. data/bundle/ruby/3.2.0/gems/parallel-1.28.0/lib/parallel/version.rb +4 -0
  18. data/bundle/ruby/3.2.0/gems/{parallel-1.27.0 → parallel-1.28.0}/lib/parallel.rb +11 -0
  19. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/io/ansi.rb +6 -4
  20. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/io/windows.rb +49 -23
  21. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/io.rb +8 -2
  22. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/line_editor.rb +49 -21
  23. data/bundle/ruby/3.2.0/gems/reline-0.7.0/lib/reline/version.rb +3 -0
  24. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline.rb +10 -9
  25. data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/CHANGES +8 -2
  26. data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/Gemfile +5 -2
  27. data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/LICENSE +1 -1
  28. data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/README.jp.md +10 -12
  29. data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/README.md +21 -26
  30. data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/embedded.rb +1 -1
  31. data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/logic_less/context.rb +4 -3
  32. data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/splat/builder.rb +18 -19
  33. data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/version.rb +1 -1
  34. data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/CHANGES +8 -0
  35. data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/README.md +1 -1
  36. data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/static_analyzer.rb +1 -1
  37. data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/string_splitter.rb +61 -5
  38. data/bundle/ruby/3.2.0/gems/temple-0.10.6/lib/temple/parser_engine.rb +34 -0
  39. data/bundle/ruby/3.2.0/gems/temple-0.10.6/lib/temple/static_analyzer.rb +148 -0
  40. data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/version.rb +1 -1
  41. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/COPYING +1 -1
  42. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/asciidoc.rb +12 -5
  43. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/babel.rb +5 -0
  44. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/builder.rb +4 -0
  45. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/coffee.rb +14 -4
  46. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/commonmarker.rb +65 -0
  47. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/csv.rb +63 -0
  48. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/erb.rb +130 -0
  49. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/erubi.rb +41 -8
  50. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/etanni.rb +7 -0
  51. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/haml.rb +67 -1
  52. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/kramdown.rb +59 -0
  53. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/liquid.rb +93 -0
  54. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/livescript.rb +11 -4
  55. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/mapping.rb +8 -8
  56. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/markaby.rb +11 -2
  57. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/nokogiri.rb +13 -2
  58. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/pandoc.rb +81 -0
  59. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/pipeline.rb +6 -1
  60. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/plain.rb +5 -1
  61. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/prawn.rb +17 -6
  62. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/radius.rb +96 -0
  63. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/rdiscount.rb +82 -0
  64. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/rdoc.rb +41 -0
  65. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/redcarpet.rb +73 -0
  66. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/redcloth.rb +40 -0
  67. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/rst-pandoc.rb +33 -0
  68. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/sass.rb +16 -3
  69. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/slim.rb +18 -0
  70. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/string.rb +10 -2
  71. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/template.rb +5 -5
  72. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/typescript.rb +5 -0
  73. data/bundle/ruby/3.2.0/gems/tilt-2.8.0/lib/tilt/yajl.rb +91 -0
  74. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt.rb +1 -2
  75. data/lib/brakeman/app_tree.rb +7 -2
  76. data/lib/brakeman/checks/check_eol_rails.rb +2 -1
  77. data/lib/brakeman/checks/check_eol_ruby.rb +1 -0
  78. data/lib/brakeman/checks/check_execute.rb +23 -19
  79. data/lib/brakeman/checks/check_model_attributes.rb +1 -1
  80. data/lib/brakeman/checks/check_render.rb +1 -27
  81. data/lib/brakeman/checks/check_render_rce.rb +43 -0
  82. data/lib/brakeman/checks/check_session_settings.rb +1 -1
  83. data/lib/brakeman/checks/check_sql.rb +4 -3
  84. data/lib/brakeman/checks.rb +31 -25
  85. data/lib/brakeman/commandline.rb +17 -5
  86. data/lib/brakeman/file_parser.rb +3 -2
  87. data/lib/brakeman/logger.rb +265 -0
  88. data/lib/brakeman/options.rb +6 -11
  89. data/lib/brakeman/parsers/rails_erubi.rb +82 -0
  90. data/lib/brakeman/parsers/template_parser.rb +7 -15
  91. data/lib/brakeman/processor.rb +2 -2
  92. data/lib/brakeman/processors/base_processor.rb +13 -6
  93. data/lib/brakeman/processors/controller_alias_processor.rb +1 -1
  94. data/lib/brakeman/processors/controller_processor.rb +3 -3
  95. data/lib/brakeman/processors/{erubis_template_processor.rb → erubi_template_procesor.rb} +3 -3
  96. data/lib/brakeman/processors/gem_processor.rb +1 -1
  97. data/lib/brakeman/processors/haml_template_processor.rb +3 -1
  98. data/lib/brakeman/processors/lib/rails2_config_processor.rb +4 -3
  99. data/lib/brakeman/processors/lib/rails2_route_processor.rb +1 -1
  100. data/lib/brakeman/processors/lib/rails3_config_processor.rb +10 -1
  101. data/lib/brakeman/processors/lib/render_helper.rb +4 -2
  102. data/lib/brakeman/processors/lib/render_path.rb +1 -1
  103. data/lib/brakeman/processors/model_processor.rb +1 -1
  104. data/lib/brakeman/report/ignore/config.rb +1 -1
  105. data/lib/brakeman/scanner.rb +33 -51
  106. data/lib/brakeman/tracker/collection.rb +12 -2
  107. data/lib/brakeman/tracker/config.rb +17 -13
  108. data/lib/brakeman/tracker/constants.rb +17 -2
  109. data/lib/brakeman/tracker/controller.rb +1 -1
  110. data/lib/brakeman/tracker.rb +7 -15
  111. data/lib/brakeman/version.rb +1 -1
  112. data/lib/brakeman.rb +109 -55
  113. metadata +182 -210
  114. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/CHANGES.txt +0 -828
  115. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/README.txt +0 -102
  116. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/contrib/erubis +0 -3468
  117. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/contrib/erubis-run.rb +0 -132
  118. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/contrib/inline-require +0 -179
  119. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/context.rb +0 -83
  120. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/converter.rb +0 -357
  121. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ec.rb +0 -117
  122. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ecpp.rb +0 -113
  123. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ejava.rb +0 -110
  124. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ejavascript.rb +0 -119
  125. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/enhanced.rb +0 -126
  126. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/eperl.rb +0 -95
  127. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb +0 -99
  128. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/eruby.rb +0 -125
  129. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/escheme.rb +0 -114
  130. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/optimized.rb +0 -127
  131. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine.rb +0 -120
  132. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/enhancer.rb +0 -723
  133. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/error.rb +0 -23
  134. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/evaluator.rb +0 -88
  135. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/generator.rb +0 -85
  136. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/helper.rb +0 -47
  137. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/helpers/rails_form_helper.rb +0 -197
  138. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/helpers/rails_helper.rb +0 -353
  139. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/local-setting.rb +0 -9
  140. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/main.rb +0 -516
  141. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb +0 -58
  142. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/tiny.rb +0 -144
  143. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/util.rb +0 -22
  144. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis.rb +0 -73
  145. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/setup.rb +0 -1331
  146. data/bundle/ruby/3.2.0/gems/parallel-1.27.0/lib/parallel/version.rb +0 -4
  147. data/bundle/ruby/3.2.0/gems/reline-0.6.3/lib/reline/version.rb +0 -3
  148. data/bundle/ruby/3.2.0/gems/temple-0.10.4/lib/temple/static_analyzer.rb +0 -78
  149. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/creole.rb +0 -16
  150. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/csv.rb +0 -53
  151. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/erb.rb +0 -65
  152. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/kramdown.rb +0 -13
  153. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/liquid.rb +0 -37
  154. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/pandoc.rb +0 -39
  155. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/radius.rb +0 -41
  156. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/rdiscount.rb +0 -23
  157. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/rdoc.rb +0 -11
  158. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/redcarpet.rb +0 -31
  159. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/redcloth.rb +0 -13
  160. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/rst-pandoc.rb +0 -10
  161. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/slim.rb +0 -5
  162. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/yajl.rb +0 -81
  163. data/lib/brakeman/parsers/erubis_patch.rb +0 -11
  164. data/lib/brakeman/parsers/rails2_erubis.rb +0 -9
  165. data/lib/brakeman/parsers/rails2_xss_plugin_erubis.rb +0 -52
  166. data/lib/brakeman/parsers/rails3_erubis.rb +0 -85
  167. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/LICENSE.txt +0 -0
  168. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv/core_ext/array.rb +0 -0
  169. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv/core_ext/string.rb +0 -0
  170. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv/fields_converter.rb +0 -0
  171. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv/input_record_separator.rb +0 -0
  172. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv/table.rb +0 -0
  173. data/bundle/ruby/3.2.0/gems/{csv-3.3.5 → csv-3.3.6}/lib/csv/writer.rb +0 -0
  174. data/bundle/ruby/3.2.0/gems/{parallel-1.27.0 → parallel-1.28.0}/MIT-LICENSE.txt +0 -0
  175. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/BSDL +0 -0
  176. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/COPYING +0 -0
  177. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/README.md +0 -0
  178. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/config.rb +0 -0
  179. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/face.rb +0 -0
  180. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/history.rb +0 -0
  181. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/io/dumb.rb +0 -0
  182. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/key_actor/base.rb +0 -0
  183. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/key_actor/composite.rb +0 -0
  184. data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/key_actor/emacs.rb +2 -2
  185. /data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/key_actor/vi_command.rb +0 -0
  186. /data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/key_actor/vi_insert.rb +0 -0
  187. /data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/key_actor.rb +0 -0
  188. /data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/key_stroke.rb +0 -0
  189. /data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/kill_ring.rb +0 -0
  190. /data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/unicode/east_asian_width.rb +0 -0
  191. /data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/lib/reline/unicode.rb +0 -0
  192. /data/bundle/ruby/3.2.0/gems/{reline-0.6.3 → reline-0.7.0}/license_of_rb-readline +0 -0
  193. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/code_attributes.rb +0 -0
  194. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/command.rb +0 -0
  195. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/controls.rb +0 -0
  196. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/do_inserter.rb +0 -0
  197. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/end_inserter.rb +0 -0
  198. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/engine.rb +0 -0
  199. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/erb_converter.rb +0 -0
  200. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/filter.rb +0 -0
  201. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/grammar.rb +0 -0
  202. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/include.rb +0 -0
  203. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/interpolation.rb +0 -0
  204. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/logic_less/filter.rb +0 -0
  205. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/logic_less.rb +0 -0
  206. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/parser.rb +0 -0
  207. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/railtie.rb +0 -0
  208. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/smart/escaper.rb +0 -0
  209. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/smart/filter.rb +0 -0
  210. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/smart/parser.rb +0 -0
  211. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/smart.rb +0 -0
  212. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/splat/filter.rb +0 -0
  213. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/template.rb +0 -0
  214. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim/translator.rb +0 -0
  215. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/lib/slim.rb +0 -0
  216. /data/bundle/ruby/3.2.0/gems/{slim-5.2.1 → slim-5.2.2}/slim.gemspec +0 -0
  217. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/EXPRESSIONS.md +0 -0
  218. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/Gemfile +0 -0
  219. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/LICENSE +0 -0
  220. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/engine.rb +0 -0
  221. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/erb/engine.rb +0 -0
  222. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/erb/parser.rb +0 -0
  223. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/erb/template.rb +0 -0
  224. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/erb/trimming.rb +0 -0
  225. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/exceptions.rb +0 -0
  226. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filter.rb +0 -0
  227. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/ambles.rb +0 -0
  228. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/code_merger.rb +0 -0
  229. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/control_flow.rb +0 -0
  230. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/dynamic_inliner.rb +0 -0
  231. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/dynamic_merger.rb +0 -0
  232. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/encoding.rb +0 -0
  233. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/eraser.rb +0 -0
  234. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/escapable.rb +0 -0
  235. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/multi_flattener.rb +0 -0
  236. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/remove_bom.rb +0 -0
  237. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/static_merger.rb +0 -0
  238. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/filters/validator.rb +0 -0
  239. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/generator.rb +0 -0
  240. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/generators/array.rb +0 -0
  241. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/generators/array_buffer.rb +0 -0
  242. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/generators/erb.rb +0 -0
  243. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/generators/rails_output_buffer.rb +0 -0
  244. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/generators/string_buffer.rb +0 -0
  245. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/grammar.rb +0 -0
  246. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/html/attribute_merger.rb +0 -0
  247. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/html/attribute_remover.rb +0 -0
  248. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/html/attribute_sorter.rb +0 -0
  249. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/html/dispatcher.rb +0 -0
  250. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/html/fast.rb +0 -0
  251. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/html/filter.rb +0 -0
  252. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/html/pretty.rb +0 -0
  253. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/html/safe.rb +0 -0
  254. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/map.rb +0 -0
  255. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/mixins/dispatcher.rb +0 -0
  256. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/mixins/engine_dsl.rb +0 -0
  257. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/mixins/grammar_dsl.rb +0 -0
  258. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/mixins/options.rb +0 -0
  259. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/mixins/template.rb +0 -0
  260. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/parser.rb +0 -0
  261. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/templates/rails.rb +0 -0
  262. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/templates/tilt.rb +0 -0
  263. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/templates.rb +0 -0
  264. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple/utils.rb +0 -0
  265. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/lib/temple.rb +0 -0
  266. /data/bundle/ruby/3.2.0/gems/{temple-0.10.4 → temple-0.10.6}/temple.gemspec +0 -0
  267. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/_emacs_org.rb +0 -0
  268. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/_handlebars.rb +0 -0
  269. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/_jbuilder.rb +0 -0
  270. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/_org.rb +0 -0
  271. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.8.0}/lib/tilt/cli.rb +0 -0
@@ -0,0 +1,151 @@
1
+ = Erubi
2
+
3
+ Erubi is a ERB template engine for ruby. It is a simplified fork of Erubis, using
4
+ the same basic algorithm, with the following differences:
5
+
6
+ * Handles postfix conditionals when using escaping (e.g. <tt><%= foo if bar %></tt>)
7
+ * Supports frozen_string_literal: true in templates via :freeze option
8
+ * Works with ruby's <tt>--enable-frozen-string-literal</tt> option
9
+ * Automatically freezes strings for template text when ruby optimizes it (on ruby 2.1+)
10
+ * Escapes <tt>'</tt> (apostrophe) when escaping for better XSS protection
11
+ * Has 15x-6x faster escaping by using erb/escape or cgi/escape
12
+ * Has 81% smaller memory footprint (calculated using +ObjectSpace.memsize_of_all+)
13
+ * Does no monkey patching (Erubis adds a method to Kernel)
14
+ * Uses an immutable design (all options passed to the constructor, which returns a frozen object)
15
+ * Has simpler internals (1 file, <150 lines of code)
16
+ * Is not dead (Erubis hasn't been updated since 2011)
17
+
18
+ It is not designed with Erubis API compatibility in mind, though most Erubis
19
+ ERB syntax works, with the following exceptions:
20
+
21
+ * No support for <tt><%===</tt> for debug output
22
+
23
+ = Installation
24
+
25
+ gem install erubi
26
+
27
+ = Source Code
28
+
29
+ Source code is available on GitHub at https://github.com/jeremyevans/erubi
30
+
31
+ = Usage
32
+
33
+ Erubi only has built in support for retrieving the generated source for a
34
+ file:
35
+
36
+ require 'erubi'
37
+ eval(Erubi::Engine.new(File.read('filename.erb')).src)
38
+
39
+ Most users will probably use Erubi via Rails or Tilt. Erubi is the default
40
+ erb template handler in Tilt 2.0.6+ and Rails 5.1+.
41
+
42
+ == Capturing
43
+
44
+ Erubi does not support capturing block output into the template by default.
45
+ It currently ships with two implementations that allow it.
46
+
47
+ === Erubi::CaptureBlockEngine
48
+
49
+ The recommended implementation can be required via +erubi/capture_block+,
50
+ which allows capturing to work with normal <tt><%=</tt> and <tt><%==</tt>
51
+ tags.
52
+
53
+ <%= form do %>
54
+ <input>
55
+ <% end %>
56
+
57
+ When using the capture_block support, capture methods should just return
58
+ the text it emit into the template, and call +capture+ on the buffer value.
59
+ Since the buffer variable is a local variable and not an instance variable
60
+ by default, you'll probably want to set the +:bufvar+ variable when using
61
+ the capture_block support to an instance variable, and have any methods
62
+ used call capture on that instance variable. Example:
63
+
64
+ def form(&block)
65
+ "<form>#{@_buf.capture(&block)}</form>"
66
+ end
67
+
68
+ puts eval(Erubi::CaptureBlockEngine.new(<<-END, bufvar: '@_buf', trim: false).src)
69
+ before
70
+ <%= form do %>
71
+ inside
72
+ <% end %>
73
+ after
74
+ END
75
+
76
+ # Output:
77
+ # before
78
+ # <form>
79
+ # inside
80
+ # </form>
81
+ # after
82
+
83
+ To use the capture_block support with tilt:
84
+
85
+ require 'tilt'
86
+ require 'erubi/capture_block'
87
+ Tilt.new("filename.erb", :engine_class=>Erubi::CaptureBlockEngine).render
88
+
89
+ Note that the capture_block support, while very compatible with the default
90
+ support, is not 100% compatible. One area where behavior differs is when
91
+ using multiple statements inside <tt><%=</tt> and <tt><%==</tt> tags:
92
+
93
+ <%= 1; 2 %>
94
+
95
+ The default support will output 2, but the capture_block support will output
96
+ 1.
97
+
98
+ === Erubi::CaptureEndEngine
99
+
100
+ An alternative capture implementation can be required via +erubi/capture_end+,
101
+ which supports it via <tt><%|=</tt> and <tt><%|==</tt> tags which are
102
+ closed with a <tt><%|</tt> tag:
103
+
104
+ <%|= form do %>
105
+ <input>
106
+ <%| end %>
107
+
108
+ It is only recommended to use +erubi/capture_end+ for backwards
109
+ compatibilty.
110
+
111
+ When using the capture_end support, capture methods (such as +form+ in the example
112
+ above) should return the (potentially modified) buffer. Similar to the
113
+ capture_block support, using an instance variable is recommended. Example:
114
+
115
+ def form
116
+ @_buf << "<form>"
117
+ yield
118
+ @_buf << "</form>"
119
+ @_buf
120
+ end
121
+
122
+ puts eval(Erubi::CaptureEndEngine.new(<<-END, bufvar: '@_buf').src)
123
+ before
124
+ <%|= form do %>
125
+ inside
126
+ <%| end %>
127
+ after
128
+ END
129
+
130
+ # Output:
131
+ # before
132
+ # <form>
133
+ # inside
134
+ # </form>
135
+ # after
136
+
137
+ Alternatively, passing the option <tt>:yield_returns_buffer => true</tt> will return the
138
+ buffer captured by the block instead of the last expression in the block.
139
+
140
+ = Reporting Bugs
141
+
142
+ The bug tracker is located at https://github.com/jeremyevans/erubi/issues
143
+
144
+ = License
145
+
146
+ MIT
147
+
148
+ = Authors
149
+
150
+ Jeremy Evans <code@jeremyevans.net>
151
+ kuwata-lab.com
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'erubi'
4
+
5
+ module Erubi
6
+ # An engine class that supports capturing blocks via the <tt><%=</tt> and <tt><%==</tt> tags:
7
+ #
8
+ # <%= upcase_form do %>
9
+ # <%= 'foo' %>
10
+ # <% end %>
11
+ #
12
+ # Where +upcase_form+ is defined like:
13
+ #
14
+ # def upcase_form(&block)
15
+ # "<form>#{@bufvar.capture(&block).upcase}</form>"
16
+ # end
17
+ #
18
+ # With output being:
19
+ #
20
+ # <form>
21
+ # FOO
22
+ # </form>
23
+ #
24
+ # This requires using a string subclass as the buffer value, provided by the
25
+ # CaptureBlockEngine::Buffer class.
26
+ #
27
+ # This engine does not support the :escapefunc option. To change the escaping function,
28
+ # use a subclass of CaptureBlockEngine::Buffer and override the #| method.
29
+ #
30
+ # This engine does not support the :chain_appends option, and ignores it if present.
31
+ class CaptureBlockEngine < Engine
32
+ class Buffer < ::String
33
+
34
+ # Convert argument to string when concatening
35
+ def <<(v)
36
+ concat(v.to_s)
37
+ end
38
+
39
+ # Escape argument using Erubi.h then then concatenate it to the receiver.
40
+ def |(v)
41
+ concat(h(v))
42
+ end
43
+
44
+ # Temporarily clear the receiver before yielding to the block, yield the
45
+ # given args to the block, return any data captured by the receiver, and
46
+ # restore the original data the receiver contained before returning.
47
+ def capture(*args)
48
+ prev = dup
49
+ replace("") # 1.8 support!
50
+ yield(*args)
51
+ dup
52
+ ensure
53
+ replace(prev)
54
+ end
55
+
56
+ private
57
+
58
+ if RUBY_VERSION >= '2'
59
+ define_method(:h, ::Erubi.instance_method(:h))
60
+ # :nocov:
61
+ else
62
+ def h(v)
63
+ ::Erubi.h(v)
64
+ end
65
+ end
66
+ # :nocov:
67
+ end
68
+
69
+ def initialize(input, properties={})
70
+ properties = Hash[properties]
71
+ properties[:bufval] ||= '::Erubi::CaptureBlockEngine::Buffer.new'
72
+ properties[:chain_appends] = false
73
+ super
74
+ end
75
+
76
+ private
77
+
78
+ def add_expression_result(code)
79
+ add_expression_op(' <<= ', code)
80
+ end
81
+
82
+ def add_expression_result_escaped(code)
83
+ add_expression_op(' |= ', code)
84
+ end
85
+
86
+ def add_expression_op(op, code)
87
+ check = /\A\s*\z/.send(MATCH_METHOD, code) ? "''" : ''
88
+ with_buffer{@src << op << check << code}
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'erubi'
4
+
5
+ module Erubi
6
+ # An engine class that supports capturing blocks via the <tt><%|=</tt> and <tt><%|==</tt> tags,
7
+ # explicitly ending the captures using <tt><%|</tt> end <tt>%></tt> blocks.
8
+ class CaptureEndEngine < Engine
9
+ # Initializes the engine. Accepts the same arguments as ::Erubi::Engine, and these
10
+ # additional options:
11
+ # :escape_capture :: Whether to make <tt><%|=</tt> escape by default, and <tt><%|==</tt> not escape by default,
12
+ # defaults to the same value as :escape.
13
+ # :yield_returns_buffer :: Whether to have <tt><%|</tt> tags insert the buffer as an expression, so that
14
+ # <tt><%| end %></tt> tags will have the buffer be the last expression inside
15
+ # the block, and therefore have the buffer be returned by the yield
16
+ # expression. Normally the buffer will be returned anyway, but there
17
+ # are cases where the last expression will not be the buffer,
18
+ # and therefore a different object will be returned.
19
+ def initialize(input, properties={})
20
+ properties = Hash[properties]
21
+ escape = properties.fetch(:escape){properties.fetch(:escape_html, false)}
22
+ @escape_capture = properties.fetch(:escape_capture, escape)
23
+ @yield_returns_buffer = properties.fetch(:yield_returns_buffer, false)
24
+ @bufval = properties[:bufval] ||= '::String.new'
25
+ @bufstack = '__erubi_stack'
26
+ properties[:regexp] ||= /<%(\|?={1,2}|-|\#|%|\|)?(.*?)([-=])?%>([ \t]*\r?\n)?/m
27
+ super
28
+ end
29
+
30
+ private
31
+
32
+ # Handle the <%|= and <%|== tags
33
+ def handle(indicator, code, tailch, rspace, lspace)
34
+ case indicator
35
+ when '|=', '|=='
36
+ rspace = nil if tailch && !tailch.empty?
37
+ add_text(lspace) if lspace
38
+ escape_capture = !((indicator == '|=') ^ @escape_capture)
39
+ terminate_expression
40
+ @src << "begin; (#{@bufstack} ||= []) << #{@bufvar}; #{@bufvar} = #{@bufval}; #{@bufstack}.last << #{@escapefunc if escape_capture}((" << code
41
+ @buffer_on_stack = false
42
+ add_text(rspace) if rspace
43
+ when '|'
44
+ rspace = nil if tailch && !tailch.empty?
45
+ add_text(lspace) if lspace
46
+ if @yield_returns_buffer
47
+ terminate_expression
48
+ @src << " #{@bufvar}; "
49
+ end
50
+ @src << code << ")).to_s; ensure; #{@bufvar} = #{@bufstack}.pop; end;"
51
+ @buffer_on_stack = false
52
+ add_text(rspace) if rspace
53
+ else
54
+ super
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,299 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Erubi
4
+ VERSION = '1.13.1'
5
+
6
+ # :nocov:
7
+ if RUBY_VERSION >= '1.9'
8
+ RANGE_FIRST = 0
9
+ RANGE_LAST = -1
10
+ else
11
+ RANGE_FIRST = 0..0
12
+ RANGE_LAST = -1..-1
13
+ end
14
+
15
+ MATCH_METHOD = RUBY_VERSION >= '2.4' ? :match? : :match
16
+ SKIP_DEFINED_FOR_INSTANCE_VARIABLE = RUBY_VERSION > '3'
17
+ FREEZE_TEMPLATE_LITERALS = !eval("''").frozen? && RUBY_VERSION >= '2.1'
18
+ # :nocov:
19
+
20
+ begin
21
+ require 'erb/escape'
22
+ define_method(:h, ERB::Escape.instance_method(:html_escape))
23
+ # :nocov:
24
+ rescue LoadError
25
+ begin
26
+ require 'cgi/escape'
27
+ unless CGI.respond_to?(:escapeHTML) # work around for JRuby 9.1
28
+ CGI = Object.new
29
+ CGI.extend(defined?(::CGI::Escape) ? ::CGI::Escape : ::CGI::Util)
30
+ end
31
+ # Escape characters with their HTML/XML equivalents.
32
+ def h(value)
33
+ CGI.escapeHTML(value.to_s)
34
+ end
35
+ rescue LoadError
36
+ ESCAPE_TABLE = {'&' => '&amp;'.freeze, '<' => '&lt;'.freeze, '>' => '&gt;'.freeze, '"' => '&quot;'.freeze, "'" => '&#39;'.freeze}.freeze
37
+ if RUBY_VERSION >= '1.9'
38
+ def h(value)
39
+ value.to_s.gsub(/[&<>"']/, ESCAPE_TABLE)
40
+ end
41
+ else
42
+ def h(value)
43
+ value.to_s.gsub(/[&<>"']/){|s| ESCAPE_TABLE[s]}
44
+ end
45
+ end
46
+ end
47
+ end
48
+ # :nocov:
49
+ module_function :h
50
+
51
+ class Engine
52
+ # The default regular expression used for scanning.
53
+ DEFAULT_REGEXP = /<%(={1,2}|-|\#|%)?(.*?)([-=])?%>([ \t]*\r?\n)?/m
54
+
55
+ # The frozen ruby source code generated from the template, which can be evaled.
56
+ attr_reader :src
57
+
58
+ # The filename of the template, if one was given.
59
+ attr_reader :filename
60
+
61
+ # The variable name used for the buffer variable.
62
+ attr_reader :bufvar
63
+
64
+ # Initialize a new Erubi::Engine. Options:
65
+ # +:bufval+ :: The value to use for the buffer variable, as a string (default <tt>'::String.new'</tt>).
66
+ # +:bufvar+ :: The variable name to use for the buffer variable, as a string.
67
+ # +:chain_appends+ :: Whether to chain <tt><<</t> calls to the buffer variable. Offers better
68
+ # performance, but can cause issues when the buffer variable is reassigned during
69
+ # template rendering (default +false+).
70
+ # +:ensure+ :: Wrap the template in a begin/ensure block restoring the previous value of bufvar.
71
+ # +:escapefunc+ :: The function to use for escaping, as a string (default: <tt>'::Erubi.h'</tt>).
72
+ # +:escape+ :: Whether to make <tt><%=</tt> escape by default, and <tt><%==</tt> not escape by default.
73
+ # +:escape_html+ :: Same as +:escape+, with lower priority.
74
+ # +:filename+ :: The filename for the template.
75
+ # +:freeze+ :: Whether to enable add a <tt>frozen_string_literal: true</tt> magic comment at the top of
76
+ # the resulting source code. Note this may cause problems if you are wrapping the resulting
77
+ # source code in other code, because the magic comment only has an effect at the beginning of
78
+ # the file, and having the magic comment later in the file can trigger warnings.
79
+ # +:freeze_template_literals+ :: Whether to suffix all literal strings for template code with <tt>.freeze</tt>
80
+ # (default: +true+ on Ruby 2.1+, +false+ on Ruby 2.0 and older).
81
+ # Can be set to +false+ on Ruby 2.3+ when frozen string literals are enabled
82
+ # in order to improve performance.
83
+ # +:literal_prefix+ :: The prefix to output when using escaped tag delimiters (default <tt>'<%'</tt>).
84
+ # +:literal_postfix+ :: The postfix to output when using escaped tag delimiters (default <tt>'%>'</tt>).
85
+ # +:outvar+ :: Same as +:bufvar+, with lower priority.
86
+ # +:postamble+ :: The postamble for the template, by default returns the resulting source code.
87
+ # +:preamble+ :: The preamble for the template, by default initializes the buffer variable.
88
+ # +:regexp+ :: The regexp to use for scanning.
89
+ # +:src+ :: The initial value to use for the source code, an empty string by default.
90
+ # +:trim+ :: Whether to trim leading and trailing whitespace, true by default.
91
+ def initialize(input, properties={})
92
+ @escape = escape = properties.fetch(:escape){properties.fetch(:escape_html, false)}
93
+ trim = properties[:trim] != false
94
+ @filename = properties[:filename]
95
+ @bufvar = bufvar = properties[:bufvar] || properties[:outvar] || "_buf"
96
+ bufval = properties[:bufval] || '::String.new'
97
+ regexp = properties[:regexp] || DEFAULT_REGEXP
98
+ literal_prefix = properties[:literal_prefix] || '<%'
99
+ literal_postfix = properties[:literal_postfix] || '%>'
100
+ preamble = properties[:preamble] || "#{bufvar} = #{bufval};"
101
+ postamble = properties[:postamble] || "#{bufvar}.to_s\n"
102
+ @chain_appends = properties[:chain_appends]
103
+ @text_end = if properties.fetch(:freeze_template_literals, FREEZE_TEMPLATE_LITERALS)
104
+ "'.freeze"
105
+ else
106
+ "'"
107
+ end
108
+
109
+ @buffer_on_stack = false
110
+ @src = src = properties[:src] || String.new
111
+ src << "# frozen_string_literal: true\n" if properties[:freeze]
112
+ if properties[:ensure]
113
+ src << "begin; __original_outvar = #{bufvar}"
114
+ if SKIP_DEFINED_FOR_INSTANCE_VARIABLE && /\A@[^@]/ =~ bufvar
115
+ src << "; "
116
+ else
117
+ src << " if defined?(#{bufvar}); "
118
+ end
119
+ end
120
+
121
+ unless @escapefunc = properties[:escapefunc]
122
+ if escape
123
+ @escapefunc = '__erubi.h'
124
+ src << "__erubi = ::Erubi; "
125
+ else
126
+ @escapefunc = '::Erubi.h'
127
+ end
128
+ end
129
+
130
+ src << preamble
131
+
132
+ pos = 0
133
+ is_bol = true
134
+ input.scan(regexp) do |indicator, code, tailch, rspace|
135
+ match = Regexp.last_match
136
+ len = match.begin(0) - pos
137
+ text = input[pos, len]
138
+ pos = match.end(0)
139
+ ch = indicator ? indicator[RANGE_FIRST] : nil
140
+
141
+ lspace = nil
142
+
143
+ unless ch == '='
144
+ if text.empty?
145
+ lspace = "" if is_bol
146
+ elsif text[RANGE_LAST] == "\n"
147
+ lspace = ""
148
+ else
149
+ rindex = text.rindex("\n")
150
+ if rindex
151
+ range = rindex+1..-1
152
+ s = text[range]
153
+ if /\A[ \t]*\z/.send(MATCH_METHOD, s)
154
+ lspace = s
155
+ text[range] = ''
156
+ end
157
+ else
158
+ if is_bol && /\A[ \t]*\z/.send(MATCH_METHOD, text)
159
+ lspace = text
160
+ text = ''
161
+ end
162
+ end
163
+ end
164
+ end
165
+
166
+ is_bol = rspace
167
+ add_text(text)
168
+ case ch
169
+ when '='
170
+ rspace = nil if tailch && !tailch.empty?
171
+ add_expression(indicator, code)
172
+ add_text(rspace) if rspace
173
+ when nil, '-'
174
+ if trim && lspace && rspace
175
+ add_code("#{lspace}#{code}#{rspace}")
176
+ else
177
+ add_text(lspace) if lspace
178
+ add_code(code)
179
+ add_text(rspace) if rspace
180
+ end
181
+ when '#'
182
+ n = code.count("\n") + (rspace ? 1 : 0)
183
+ if trim && lspace && rspace
184
+ add_code("\n" * n)
185
+ else
186
+ add_text(lspace) if lspace
187
+ add_code("\n" * n)
188
+ add_text(rspace) if rspace
189
+ end
190
+ when '%'
191
+ add_text("#{lspace}#{literal_prefix}#{code}#{tailch}#{literal_postfix}#{rspace}")
192
+ else
193
+ handle(indicator, code, tailch, rspace, lspace)
194
+ end
195
+ end
196
+ rest = pos == 0 ? input : input[pos..-1]
197
+ add_text(rest)
198
+
199
+ src << "\n" unless src[RANGE_LAST] == "\n"
200
+ add_postamble(postamble)
201
+ src << "; ensure\n " << bufvar << " = __original_outvar\nend\n" if properties[:ensure]
202
+ src.freeze
203
+ freeze
204
+ end
205
+
206
+ private
207
+
208
+ if RUBY_VERSION >= '2.3'
209
+ def _dup_string_if_frozen(string)
210
+ +string
211
+ end
212
+ # :nocov:
213
+ else
214
+ def _dup_string_if_frozen(string)
215
+ string.frozen? ? string.dup : string
216
+ end
217
+ end
218
+ # :nocov:
219
+
220
+ # Add raw text to the template. Modifies argument if argument is mutable as a memory optimization.
221
+ # Must be called with a string, cannot be called with nil (Rails's subclass depends on it).
222
+ def add_text(text)
223
+ return if text.empty?
224
+
225
+ text = _dup_string_if_frozen(text)
226
+ text.gsub!(/['\\]/, '\\\\\&')
227
+
228
+ with_buffer{@src << " << '" << text << @text_end}
229
+ end
230
+
231
+ # Add ruby code to the template
232
+ def add_code(code)
233
+ terminate_expression
234
+ @src << code
235
+ @src << ';' unless code[RANGE_LAST] == "\n"
236
+ @buffer_on_stack = false
237
+ end
238
+
239
+ # Add the given ruby expression result to the template,
240
+ # escaping it based on the indicator given and escape flag.
241
+ def add_expression(indicator, code)
242
+ if ((indicator == '=') ^ @escape)
243
+ add_expression_result(code)
244
+ else
245
+ add_expression_result_escaped(code)
246
+ end
247
+ end
248
+
249
+ # Add the result of Ruby expression to the template
250
+ def add_expression_result(code)
251
+ with_buffer{@src << ' << (' << code << ').to_s'}
252
+ end
253
+
254
+ # Add the escaped result of Ruby expression to the template
255
+ def add_expression_result_escaped(code)
256
+ with_buffer{@src << ' << ' << @escapefunc << '((' << code << '))'}
257
+ end
258
+
259
+ # Add the given postamble to the src. Can be overridden in subclasses
260
+ # to make additional changes to src that depend on the current state.
261
+ def add_postamble(postamble)
262
+ terminate_expression
263
+ @src << postamble
264
+ end
265
+
266
+ # Raise an exception, as the base engine class does not support handling other indicators.
267
+ def handle(indicator, code, tailch, rspace, lspace)
268
+ raise ArgumentError, "Invalid indicator: #{indicator}"
269
+ end
270
+
271
+ # Make sure the buffer variable is the target of the next append
272
+ # before yielding to the block. Mark that the buffer is the target
273
+ # of the next append after the block executes.
274
+ #
275
+ # This method should only be called if the block will result in
276
+ # code where << will append to the bufvar.
277
+ def with_buffer
278
+ if @chain_appends
279
+ unless @buffer_on_stack
280
+ @src << '; ' << @bufvar
281
+ end
282
+ yield
283
+ @buffer_on_stack = true
284
+ else
285
+ @src << ' ' << @bufvar
286
+ yield
287
+ @src << ';'
288
+ end
289
+ end
290
+
291
+ # Make sure that any current expression has been terminated.
292
+ # The default is to terminate all expressions, but when
293
+ # the chain_appends option is used, expressions may not be
294
+ # terminated.
295
+ def terminate_expression
296
+ @src << '; ' if @chain_appends
297
+ end
298
+ end
299
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ module Parallel
3
+ VERSION = Version = '1.28.0' # rubocop:disable Naming/ConstantName
4
+ end
@@ -15,6 +15,17 @@ module Parallel
15
15
  super()
16
16
  @value = value
17
17
  end
18
+
19
+ # marshal_dump that is used for ruby exceptions
20
+ # avoid dumping the cause since nobody needs that and it can include undumpable exceptions
21
+ def _dump(_depth)
22
+ Marshal.dump(@value)
23
+ end
24
+
25
+ # marshal_load that is used for ruby exceptions
26
+ def self._load(data)
27
+ new(Marshal.load(data))
28
+ end
18
29
  end
19
30
 
20
31
  class Kill < Break
@@ -114,13 +114,15 @@ class Reline::ANSI < Reline::IO
114
114
  end
115
115
 
116
116
  def inner_getc(timeout_second)
117
- unless @buf.empty?
118
- return @buf.shift
119
- end
120
- until @input.wait_readable(0.01)
117
+ while true
118
+ # @buf may change while handling signal, so we need to check it in each loop iteration.
119
+ return @buf.shift unless @buf.empty?
120
+ break if @input.wait_readable(0.01)
121
+
121
122
  timeout_second -= 0.01
122
123
  return nil if timeout_second <= 0
123
124
 
125
+ # handle_signal may call cursor_pos which modifies @buf
124
126
  Reline.core.line_editor.handle_signal
125
127
  end
126
128
  c = @input.getbyte