brakeman 4.6.1 → 4.7.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 (251) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +11 -0
  3. data/bundle/load.rb +7 -7
  4. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/CHANGELOG.md +122 -4
  5. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/FAQ.md +4 -14
  6. data/bundle/ruby/2.6.0/gems/haml-5.1.2/Gemfile +19 -0
  7. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/MIT-LICENSE +2 -2
  8. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/README.md +80 -42
  9. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/REFERENCE.md +121 -64
  10. data/bundle/ruby/2.6.0/gems/haml-5.1.2/TODO +24 -0
  11. data/bundle/ruby/2.6.0/gems/haml-5.1.2/haml.gemspec +44 -0
  12. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/lib/haml.rb +2 -0
  13. data/bundle/ruby/2.6.0/gems/haml-5.1.2/lib/haml/attribute_builder.rb +164 -0
  14. data/bundle/ruby/2.6.0/gems/haml-5.1.2/lib/haml/attribute_compiler.rb +224 -0
  15. data/bundle/ruby/2.6.0/gems/haml-5.1.2/lib/haml/attribute_parser.rb +150 -0
  16. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/lib/haml/buffer.rb +25 -132
  17. data/bundle/ruby/2.6.0/gems/haml-5.1.2/lib/haml/compiler.rb +330 -0
  18. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/lib/haml/engine.rb +34 -41
  19. data/bundle/ruby/2.6.0/gems/haml-5.1.2/lib/haml/error.rb +65 -0
  20. data/bundle/ruby/2.6.0/gems/haml-5.1.2/lib/haml/escapable.rb +50 -0
  21. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/lib/haml/exec.rb +38 -20
  22. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/lib/haml/filters.rb +22 -27
  23. data/bundle/ruby/2.6.0/gems/haml-5.1.2/lib/haml/generator.rb +42 -0
  24. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/lib/haml/helpers.rb +129 -90
  25. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/lib/haml/helpers/action_view_extensions.rb +4 -2
  26. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/lib/haml/helpers/action_view_mods.rb +45 -60
  27. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/lib/haml/helpers/action_view_xss_mods.rb +2 -0
  28. data/bundle/ruby/2.6.0/gems/haml-5.1.2/lib/haml/helpers/safe_erubi_template.rb +20 -0
  29. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/lib/haml/helpers/safe_erubis_template.rb +5 -1
  30. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/lib/haml/helpers/xss_mods.rb +19 -12
  31. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/lib/haml/options.rb +63 -69
  32. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/lib/haml/parser.rb +292 -228
  33. data/bundle/ruby/2.6.0/gems/haml-5.1.2/lib/haml/plugin.rb +37 -0
  34. data/bundle/ruby/2.6.0/gems/haml-5.1.2/lib/haml/railtie.rb +48 -0
  35. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/lib/haml/sass_rails_filter.rb +18 -4
  36. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/lib/haml/template.rb +13 -6
  37. data/bundle/ruby/2.6.0/gems/{haml-4.0.7 → haml-5.1.2}/lib/haml/template/options.rb +13 -2
  38. data/bundle/ruby/2.6.0/gems/haml-5.1.2/lib/haml/temple_engine.rb +123 -0
  39. data/bundle/ruby/2.6.0/gems/haml-5.1.2/lib/haml/temple_line_counter.rb +30 -0
  40. data/bundle/ruby/2.6.0/gems/haml-5.1.2/lib/haml/util.rb +258 -0
  41. data/bundle/ruby/2.6.0/gems/haml-5.1.2/lib/haml/version.rb +5 -0
  42. data/bundle/ruby/2.6.0/gems/haml-5.1.2/yard/default/fulldoc/html/css/common.sass +15 -0
  43. data/bundle/ruby/2.6.0/gems/haml-5.1.2/yard/default/layout/html/footer.erb +12 -0
  44. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/AUTHORS +0 -0
  45. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/COPYING +0 -0
  46. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/Changelog.md +3 -0
  47. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/Gemfile +0 -0
  48. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/LICENSE +0 -0
  49. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/README.md +0 -0
  50. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/TODO +0 -0
  51. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/appveyor.yml +0 -0
  52. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/highline.gemspec +0 -0
  53. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline.rb +0 -0
  54. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/builtin_styles.rb +0 -0
  55. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/color_scheme.rb +0 -0
  56. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/compatibility.rb +0 -0
  57. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/custom_errors.rb +0 -0
  58. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/import.rb +0 -0
  59. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/io_console_compatible.rb +0 -0
  60. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/list.rb +0 -0
  61. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/list_renderer.rb +0 -0
  62. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/menu.rb +0 -0
  63. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/menu/item.rb +0 -0
  64. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/paginator.rb +0 -0
  65. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/question.rb +0 -0
  66. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/question/answer_converter.rb +0 -0
  67. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/question_asker.rb +0 -0
  68. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/simulate.rb +0 -0
  69. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/statement.rb +0 -0
  70. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/string.rb +0 -0
  71. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/string_extensions.rb +0 -0
  72. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/style.rb +0 -0
  73. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/template_renderer.rb +0 -0
  74. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/terminal.rb +0 -0
  75. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/terminal/io_console.rb +0 -0
  76. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/terminal/ncurses.rb +0 -0
  77. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/terminal/unix_stty.rb +0 -0
  78. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/version.rb +1 -1
  79. data/bundle/ruby/2.6.0/gems/{highline-2.0.2 → highline-2.0.3}/lib/highline/wrapper.rb +0 -0
  80. data/bundle/ruby/2.6.0/gems/{ruby2ruby-2.4.3 → ruby2ruby-2.4.4}/History.rdoc +6 -0
  81. data/bundle/ruby/2.6.0/gems/{ruby2ruby-2.4.3 → ruby2ruby-2.4.4}/Manifest.txt +0 -0
  82. data/bundle/ruby/2.6.0/gems/{ruby2ruby-2.4.3 → ruby2ruby-2.4.4}/README.rdoc +0 -0
  83. data/bundle/ruby/2.6.0/gems/{ruby2ruby-2.4.3 → ruby2ruby-2.4.4}/lib/ruby2ruby.rb +3 -3
  84. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/History.rdoc +38 -0
  85. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/Manifest.txt +0 -0
  86. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/README.rdoc +3 -3
  87. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/compare/normalize.rb +0 -0
  88. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/debugging.md +0 -0
  89. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/lib/rp_extensions.rb +0 -0
  90. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/lib/rp_stringscanner.rb +0 -0
  91. data/bundle/ruby/2.6.0/gems/ruby_parser-3.14.0/lib/ruby20_parser.rb +7045 -0
  92. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1/lib/ruby_parser.yy → ruby_parser-3.14.0/lib/ruby20_parser.y} +390 -397
  93. data/bundle/ruby/2.6.0/gems/ruby_parser-3.14.0/lib/ruby21_parser.rb +7116 -0
  94. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/lib/ruby21_parser.y +399 -254
  95. data/bundle/ruby/2.6.0/gems/ruby_parser-3.14.0/lib/ruby22_parser.rb +7149 -0
  96. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/lib/ruby22_parser.y +400 -255
  97. data/bundle/ruby/2.6.0/gems/ruby_parser-3.14.0/lib/ruby23_parser.rb +7166 -0
  98. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/lib/ruby23_parser.y +400 -255
  99. data/bundle/ruby/2.6.0/gems/ruby_parser-3.14.0/lib/ruby24_parser.rb +7178 -0
  100. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/lib/ruby24_parser.y +404 -257
  101. data/bundle/ruby/2.6.0/gems/ruby_parser-3.14.0/lib/ruby25_parser.rb +7178 -0
  102. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/lib/ruby25_parser.y +404 -257
  103. data/bundle/ruby/2.6.0/gems/ruby_parser-3.14.0/lib/ruby26_parser.rb +7198 -0
  104. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/lib/ruby26_parser.y +410 -261
  105. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/lib/ruby_lexer.rb +424 -432
  106. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/lib/ruby_lexer.rex +0 -0
  107. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/lib/ruby_lexer.rex.rb +1 -1
  108. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/lib/ruby_parser.rb +27 -27
  109. data/bundle/ruby/2.6.0/gems/ruby_parser-3.14.0/lib/ruby_parser.yy +2732 -0
  110. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/lib/ruby_parser_extras.rb +627 -406
  111. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/tools/munge.rb +1 -1
  112. data/bundle/ruby/2.6.0/gems/{ruby_parser-3.13.1 → ruby_parser-3.14.0}/tools/ripper.rb +13 -2
  113. data/bundle/ruby/2.6.0/gems/{sexp_processor-4.12.1 → sexp_processor-4.13.0}/History.rdoc +13 -0
  114. data/bundle/ruby/2.6.0/gems/{sexp_processor-4.12.1 → sexp_processor-4.13.0}/Manifest.txt +1 -0
  115. data/bundle/ruby/2.6.0/gems/{sexp_processor-4.12.1 → sexp_processor-4.13.0}/README.rdoc +0 -0
  116. data/bundle/ruby/2.6.0/gems/{sexp_processor-4.12.1 → sexp_processor-4.13.0}/lib/composite_sexp_processor.rb +0 -0
  117. data/bundle/ruby/2.6.0/gems/{sexp_processor-4.12.1 → sexp_processor-4.13.0}/lib/pt_testcase.rb +0 -0
  118. data/bundle/ruby/2.6.0/gems/sexp_processor-4.13.0/lib/sexp.rb +381 -0
  119. data/bundle/ruby/2.6.0/gems/{sexp_processor-4.12.1/lib/sexp.rb → sexp_processor-4.13.0/lib/sexp_matcher.rb} +25 -385
  120. data/bundle/ruby/2.6.0/gems/{sexp_processor-4.12.1 → sexp_processor-4.13.0}/lib/sexp_processor.rb +1 -1
  121. data/bundle/ruby/2.6.0/gems/{sexp_processor-4.12.1 → sexp_processor-4.13.0}/lib/strict_sexp.rb +0 -0
  122. data/bundle/ruby/2.6.0/gems/{sexp_processor-4.12.1 → sexp_processor-4.13.0}/lib/unique.rb +0 -0
  123. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/CHANGES +5 -0
  124. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/EXPRESSIONS.md +0 -0
  125. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/Gemfile +0 -0
  126. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/LICENSE +0 -0
  127. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/README.md +1 -1
  128. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple.rb +0 -0
  129. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/engine.rb +0 -0
  130. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/erb/engine.rb +0 -0
  131. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/erb/parser.rb +0 -0
  132. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/erb/template.rb +0 -0
  133. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/erb/trimming.rb +0 -0
  134. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/exceptions.rb +0 -0
  135. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/filter.rb +0 -0
  136. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/filters/code_merger.rb +0 -0
  137. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/filters/control_flow.rb +0 -0
  138. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/filters/dynamic_inliner.rb +0 -0
  139. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/filters/encoding.rb +0 -0
  140. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/filters/eraser.rb +0 -0
  141. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/filters/escapable.rb +0 -0
  142. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/filters/multi_flattener.rb +0 -0
  143. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/filters/remove_bom.rb +0 -0
  144. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/filters/static_analyzer.rb +0 -0
  145. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/filters/static_merger.rb +0 -0
  146. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/filters/string_splitter.rb +1 -1
  147. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/filters/validator.rb +0 -0
  148. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/generator.rb +0 -0
  149. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/generators/array.rb +0 -0
  150. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/generators/array_buffer.rb +0 -0
  151. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/generators/erb.rb +0 -0
  152. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/generators/rails_output_buffer.rb +0 -0
  153. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/generators/string_buffer.rb +0 -0
  154. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/grammar.rb +0 -0
  155. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/html/attribute_merger.rb +0 -0
  156. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/html/attribute_remover.rb +0 -0
  157. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/html/attribute_sorter.rb +0 -0
  158. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/html/dispatcher.rb +0 -0
  159. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/html/fast.rb +0 -0
  160. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/html/filter.rb +0 -0
  161. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/html/pretty.rb +0 -0
  162. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/html/safe.rb +0 -0
  163. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/map.rb +0 -0
  164. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/mixins/dispatcher.rb +0 -0
  165. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/mixins/engine_dsl.rb +0 -0
  166. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/mixins/grammar_dsl.rb +0 -0
  167. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/mixins/options.rb +0 -0
  168. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/mixins/template.rb +0 -0
  169. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/parser.rb +0 -0
  170. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/static_analyzer.rb +1 -1
  171. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/templates.rb +0 -0
  172. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/templates/rails.rb +0 -0
  173. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/templates/tilt.rb +0 -0
  174. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/lib/temple/utils.rb +0 -0
  175. data/bundle/ruby/2.6.0/gems/temple-0.8.2/lib/temple/version.rb +3 -0
  176. data/bundle/ruby/2.6.0/gems/{temple-0.8.1 → temple-0.8.2}/temple.gemspec +0 -0
  177. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/COPYING +0 -0
  178. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt.rb +1 -1
  179. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/asciidoc.rb +0 -0
  180. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/babel.rb +0 -0
  181. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/bluecloth.rb +0 -0
  182. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/builder.rb +0 -0
  183. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/coffee.rb +0 -0
  184. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/commonmarker.rb +0 -0
  185. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/creole.rb +0 -0
  186. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/csv.rb +0 -0
  187. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/dummy.rb +0 -0
  188. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/erb.rb +0 -0
  189. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/erubi.rb +0 -0
  190. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/erubis.rb +0 -0
  191. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/etanni.rb +0 -0
  192. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/haml.rb +0 -0
  193. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/kramdown.rb +0 -0
  194. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/less.rb +0 -0
  195. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/liquid.rb +0 -0
  196. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/livescript.rb +0 -0
  197. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/mapping.rb +0 -0
  198. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/markaby.rb +0 -0
  199. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/maruku.rb +0 -0
  200. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/nokogiri.rb +0 -0
  201. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/pandoc.rb +0 -0
  202. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/plain.rb +0 -0
  203. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/prawn.rb +0 -0
  204. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/radius.rb +0 -0
  205. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/rdiscount.rb +0 -0
  206. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/rdoc.rb +0 -0
  207. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/redcarpet.rb +0 -0
  208. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/redcloth.rb +0 -0
  209. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/rst-pandoc.rb +0 -0
  210. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/sass.rb +0 -0
  211. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/sigil.rb +0 -0
  212. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/string.rb +0 -0
  213. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/template.rb +7 -12
  214. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/typescript.rb +0 -0
  215. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/wikicloth.rb +0 -0
  216. data/bundle/ruby/2.6.0/gems/{tilt-2.0.9 → tilt-2.0.10}/lib/tilt/yajl.rb +0 -0
  217. data/lib/brakeman/checks/base_check.rb +23 -1
  218. data/lib/brakeman/checks/check_cookie_serialization.rb +1 -1
  219. data/lib/brakeman/checks/check_cross_site_scripting.rb +1 -1
  220. data/lib/brakeman/checks/check_execute.rb +26 -1
  221. data/lib/brakeman/differ.rb +16 -28
  222. data/lib/brakeman/parsers/haml_embedded.rb +1 -1
  223. data/lib/brakeman/parsers/template_parser.rb +3 -1
  224. data/lib/brakeman/processors/alias_processor.rb +10 -0
  225. data/lib/brakeman/processors/base_processor.rb +2 -0
  226. data/lib/brakeman/processors/haml_template_processor.rb +86 -122
  227. data/lib/brakeman/processors/lib/rails2_config_processor.rb +1 -1
  228. data/lib/brakeman/processors/template_alias_processor.rb +28 -0
  229. data/lib/brakeman/tracker/config.rb +33 -92
  230. data/lib/brakeman/version.rb +1 -1
  231. metadata +215 -206
  232. data/bundle/ruby/2.6.0/gems/haml-4.0.7/lib/haml/compiler.rb +0 -540
  233. data/bundle/ruby/2.6.0/gems/haml-4.0.7/lib/haml/error.rb +0 -61
  234. data/bundle/ruby/2.6.0/gems/haml-4.0.7/lib/haml/railtie.rb +0 -22
  235. data/bundle/ruby/2.6.0/gems/haml-4.0.7/lib/haml/template/plugin.rb +0 -41
  236. data/bundle/ruby/2.6.0/gems/haml-4.0.7/lib/haml/util.rb +0 -377
  237. data/bundle/ruby/2.6.0/gems/haml-4.0.7/lib/haml/version.rb +0 -3
  238. data/bundle/ruby/2.6.0/gems/ruby_parser-3.13.1/lib/ruby20_parser.rb +0 -6869
  239. data/bundle/ruby/2.6.0/gems/ruby_parser-3.13.1/lib/ruby20_parser.y +0 -2431
  240. data/bundle/ruby/2.6.0/gems/ruby_parser-3.13.1/lib/ruby21_parser.rb +0 -6944
  241. data/bundle/ruby/2.6.0/gems/ruby_parser-3.13.1/lib/ruby22_parser.rb +0 -6968
  242. data/bundle/ruby/2.6.0/gems/ruby_parser-3.13.1/lib/ruby23_parser.rb +0 -6987
  243. data/bundle/ruby/2.6.0/gems/ruby_parser-3.13.1/lib/ruby24_parser.rb +0 -6994
  244. data/bundle/ruby/2.6.0/gems/ruby_parser-3.13.1/lib/ruby25_parser.rb +0 -6994
  245. data/bundle/ruby/2.6.0/gems/ruby_parser-3.13.1/lib/ruby26_parser.rb +0 -7012
  246. data/bundle/ruby/2.6.0/gems/temple-0.8.1/lib/temple/version.rb +0 -3
  247. data/bundle/ruby/2.6.0/gems/tilt-2.0.9/CHANGELOG.md +0 -132
  248. data/bundle/ruby/2.6.0/gems/tilt-2.0.9/Gemfile +0 -70
  249. data/bundle/ruby/2.6.0/gems/tilt-2.0.9/HACKING +0 -16
  250. data/bundle/ruby/2.6.0/gems/tilt-2.0.9/README.md +0 -233
  251. data/bundle/ruby/2.6.0/gems/tilt-2.0.9/tilt.gemspec +0 -130
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'strscan'
2
4
 
3
5
  module Haml
@@ -59,7 +61,7 @@ module Haml
59
61
  SILENT_SCRIPT,
60
62
  ESCAPE,
61
63
  FILTER
62
- ]
64
+ ].freeze
63
65
 
64
66
  # The value of the character that designates that a line is part
65
67
  # of a multiline string.
@@ -71,26 +73,25 @@ module Haml
71
73
  # foo.each do | bar |
72
74
  # = bar
73
75
  #
74
- BLOCK_WITH_SPACES = /do[\s]*\|[\s]*[^\|]*[\s]+\|\z/
76
+ BLOCK_WITH_SPACES = /do\s*\|\s*[^\|]*\s+\|\z/
75
77
 
76
- MID_BLOCK_KEYWORDS = %w[else elsif rescue ensure end when]
77
- START_BLOCK_KEYWORDS = %w[if begin case unless]
78
+ MID_BLOCK_KEYWORDS = %w[else elsif rescue ensure end when].freeze
79
+ START_BLOCK_KEYWORDS = %w[if begin case unless].freeze
78
80
  # Try to parse assignments to block starters as best as possible
79
81
  START_BLOCK_KEYWORD_REGEX = /(?:\w+(?:,\s*\w+)*\s*=\s*)?(#{START_BLOCK_KEYWORDS.join('|')})/
80
82
  BLOCK_KEYWORD_REGEX = /^-?\s*(?:(#{MID_BLOCK_KEYWORDS.join('|')})|#{START_BLOCK_KEYWORD_REGEX.source})\b/
81
83
 
82
84
  # The Regex that matches a Doctype command.
83
- DOCTYPE_REGEX = /(\d(?:\.\d)?)?[\s]*([a-z]*)\s*([^ ]+)?/i
85
+ DOCTYPE_REGEX = /(\d(?:\.\d)?)?\s*([a-z]*)\s*([^ ]+)?/i
84
86
 
85
87
  # The Regex that matches a literal string or symbol value
86
88
  LITERAL_VALUE_REGEX = /:(\w*)|(["'])((?!\\|\#\{|\#@|\#\$|\2).|\\.)*\2/
87
89
 
88
- def initialize(template, options)
89
- # :eod is a special end-of-document marker
90
- @template = (template.rstrip).split(/\r\n|\r|\n/) + [:eod, :eod]
91
- @options = options
92
- @flat = false
93
- @index = 0
90
+ ID_KEY = 'id'.freeze
91
+ CLASS_KEY = 'class'.freeze
92
+
93
+ def initialize(options)
94
+ @options = Options.wrap(options)
94
95
  # Record the indent levels of "if" statements to validate the subsequent
95
96
  # elsif and else statements are indented at the appropriate level.
96
97
  @script_level_stack = []
@@ -98,15 +99,27 @@ module Haml
98
99
  @template_tabs = 0
99
100
  end
100
101
 
101
- def parse
102
+ def call(template)
103
+ match = template.rstrip.scan(/(([ \t]+)?(.*?))(?:\Z|\r\n|\r|\n)/m)
104
+ # discard the last match which is always blank
105
+ match.pop
106
+ @template = match.each_with_index.map do |(full, whitespace, text), index|
107
+ Line.new(whitespace, text.rstrip, full, index, self, false)
108
+ end
109
+ # Append special end-of-document marker
110
+ @template << Line.new(nil, '-#', '-#', @template.size, self, true)
111
+
102
112
  @root = @parent = ParseNode.new(:root)
103
- @haml_comment = false
113
+ @flat = false
114
+ @filter_buffer = nil
104
115
  @indentation = nil
105
116
  @line = next_line
106
117
 
107
118
  raise SyntaxError.new(Error.message(:indenting_at_start), @line.index) if @line.tabs != 0
108
119
 
109
- while next_line
120
+ loop do
121
+ next_line
122
+
110
123
  process_indent(@line) unless @line.text.empty?
111
124
 
112
125
  if flat?
@@ -118,75 +131,103 @@ module Haml
118
131
  end
119
132
 
120
133
  @tab_up = nil
121
- process_line(@line.text, @line.index) unless @line.text.empty? || @haml_comment
122
- if @parent.type != :haml_comment && (block_opened? || @tab_up)
134
+ process_line(@line) unless @line.text.empty?
135
+ if block_opened? || @tab_up
123
136
  @template_tabs += 1
124
137
  @parent = @parent.children.last
125
138
  end
126
139
 
127
- if !@haml_comment && !flat? && @next_line.tabs - @line.tabs > 1
140
+ if !flat? && @next_line.tabs - @line.tabs > 1
128
141
  raise SyntaxError.new(Error.message(:deeper_indenting, @next_line.tabs - @line.tabs), @next_line.index)
129
142
  end
130
143
 
131
144
  @line = @next_line
132
145
  end
133
-
134
146
  # Close all the open tags
135
147
  close until @parent.type == :root
136
148
  @root
137
149
  rescue Haml::Error => e
138
- e.backtrace.unshift "#{@options[:filename]}:#{(e.line ? e.line + 1 : @index) + @options[:line] - 1}"
150
+ e.backtrace.unshift "#{@options.filename}:#{(e.line ? e.line + 1 : @line.index + 1) + @options.line - 1}"
139
151
  raise
140
152
  end
141
153
 
154
+ def compute_tabs(line)
155
+ return 0 if line.text.empty? || !line.whitespace
156
+
157
+ if @indentation.nil?
158
+ @indentation = line.whitespace
159
+
160
+ if @indentation.include?(?\s) && @indentation.include?(?\t)
161
+ raise SyntaxError.new(Error.message(:cant_use_tabs_and_spaces), line.index)
162
+ end
163
+
164
+ @flat_spaces = @indentation * (@template_tabs+1) if flat?
165
+ return 1
166
+ end
167
+
168
+ tabs = line.whitespace.length / @indentation.length
169
+ return tabs if line.whitespace == @indentation * tabs
170
+ return @template_tabs + 1 if flat? && line.whitespace =~ /^#{@flat_spaces}/
171
+
172
+ message = Error.message(:inconsistent_indentation,
173
+ human_indentation(line.whitespace),
174
+ human_indentation(@indentation)
175
+ )
176
+ raise SyntaxError.new(message, line.index)
177
+ end
142
178
 
143
179
  private
144
180
 
145
181
  # @private
146
- class Line < Struct.new(:text, :unstripped, :full, :index, :compiler, :eod)
182
+ Line = Struct.new(:whitespace, :text, :full, :index, :parser, :eod) do
147
183
  alias_method :eod?, :eod
148
184
 
149
185
  # @private
150
186
  def tabs
151
- line = self
152
- @tabs ||= compiler.instance_eval do
153
- break 0 if line.text.empty? || !(whitespace = line.full[/^\s+/])
154
-
155
- if @indentation.nil?
156
- @indentation = whitespace
157
-
158
- if @indentation.include?(?\s) && @indentation.include?(?\t)
159
- raise SyntaxError.new(Error.message(:cant_use_tabs_and_spaces), line.index)
160
- end
161
-
162
- @flat_spaces = @indentation * (@template_tabs+1) if flat?
163
- break 1
164
- end
165
-
166
- tabs = whitespace.length / @indentation.length
167
- break tabs if whitespace == @indentation * tabs
168
- break @template_tabs + 1 if flat? && whitespace =~ /^#{@flat_spaces}/
187
+ @tabs ||= parser.compute_tabs(self)
188
+ end
169
189
 
170
- message = Error.message(:inconsistent_indentation,
171
- Haml::Util.human_indentation(whitespace),
172
- Haml::Util.human_indentation(@indentation)
173
- )
174
- raise SyntaxError.new(message, line.index)
175
- end
190
+ def strip!(from)
191
+ self.text = text[from..-1]
192
+ self.text.lstrip!
193
+ self
176
194
  end
177
195
  end
178
196
 
179
197
  # @private
180
- class ParseNode < Struct.new(:type, :line, :value, :parent, :children)
198
+ ParseNode = Struct.new(:type, :line, :value, :parent, :children) do
181
199
  def initialize(*args)
182
200
  super
183
201
  self.children ||= []
184
202
  end
185
203
 
186
204
  def inspect
187
- text = "(#{type} #{value.inspect}"
188
- children.each {|c| text << "\n" << c.inspect.gsub(/^/, " ")}
189
- text + ")"
205
+ %Q[(#{type} #{value.inspect}#{children.each_with_object(''.dup) {|c, s| s << "\n#{c.inspect.gsub!(/^/, ' ')}"}})].dup
206
+ end
207
+ end
208
+
209
+ # @param [String] new - Hash literal including dynamic values.
210
+ # @param [String] old - Hash literal including dynamic values or Ruby literal of multiple Hashes which MUST be interpreted as method's last arguments.
211
+ DynamicAttributes = Struct.new(:new, :old) do
212
+ undef :old=
213
+ def old=(value)
214
+ unless value =~ /\A{.*}\z/m
215
+ raise ArgumentError.new('Old attributes must start with "{" and end with "}"')
216
+ end
217
+ self[:old] = value
218
+ end
219
+
220
+ # This will be a literal for Haml::Buffer#attributes's last argument, `attributes_hashes`.
221
+ def to_literal
222
+ [new, stripped_old].compact.join(', ')
223
+ end
224
+
225
+ private
226
+
227
+ # For `%foo{ { foo: 1 }, bar: 2 }`, :old is "{ { foo: 1 }, bar: 2 }" and this method returns " { foo: 1 }, bar: 2 " for last argument.
228
+ def stripped_old
229
+ return nil if old.nil?
230
+ old.sub!(/\A{/, '').sub!(/}\z/m, '')
190
231
  end
191
232
  end
192
233
 
@@ -195,98 +236,104 @@ module Haml
195
236
  return unless line.tabs <= @template_tabs && @template_tabs > 0
196
237
 
197
238
  to_close = @template_tabs - line.tabs
198
- to_close.times {|i| close unless to_close - 1 - i == 0 && mid_block_keyword?(line.text)}
239
+ to_close.times {|i| close unless to_close - 1 - i == 0 && continuation_script?(line.text)}
240
+ end
241
+
242
+ def continuation_script?(text)
243
+ text[0] == SILENT_SCRIPT && mid_block_keyword?(text)
244
+ end
245
+
246
+ def mid_block_keyword?(text)
247
+ MID_BLOCK_KEYWORDS.include?(block_keyword(text))
199
248
  end
200
249
 
201
250
  # Processes a single line of Haml.
202
251
  #
203
252
  # This method doesn't return anything; it simply processes the line and
204
253
  # adds the appropriate code to `@precompiled`.
205
- def process_line(text, index)
206
- @index = index + 1
207
-
208
- case text[0]
209
- when DIV_CLASS; push div(text)
254
+ def process_line(line)
255
+ case line.text[0]
256
+ when DIV_CLASS; push div(line)
210
257
  when DIV_ID
211
- return push plain(text) if text[1] == ?{
212
- push div(text)
213
- when ELEMENT; push tag(text)
214
- when COMMENT; push comment(text[1..-1].strip)
258
+ return push plain(line) if %w[{ @ $].include?(line.text[1])
259
+ push div(line)
260
+ when ELEMENT; push tag(line)
261
+ when COMMENT; push comment(line.text[1..-1].lstrip)
215
262
  when SANITIZE
216
- return push plain(text[3..-1].strip, :escape_html) if text[1..2] == "=="
217
- return push script(text[2..-1].strip, :escape_html) if text[1] == SCRIPT
218
- return push flat_script(text[2..-1].strip, :escape_html) if text[1] == FLAT_SCRIPT
219
- return push plain(text[1..-1].strip, :escape_html) if text[1] == ?\s
220
- push plain(text)
263
+ return push plain(line.strip!(3), :escape_html) if line.text[1, 2] == '=='
264
+ return push script(line.strip!(2), :escape_html) if line.text[1] == SCRIPT
265
+ return push flat_script(line.strip!(2), :escape_html) if line.text[1] == FLAT_SCRIPT
266
+ return push plain(line.strip!(1), :escape_html) if line.text[1] == ?\s || line.text[1..2] == '#{'
267
+ push plain(line)
221
268
  when SCRIPT
222
- return push plain(text[2..-1].strip) if text[1] == SCRIPT
223
- push script(text[1..-1])
224
- when FLAT_SCRIPT; push flat_script(text[1..-1])
225
- when SILENT_SCRIPT; push silent_script(text)
226
- when FILTER; push filter(text[1..-1].downcase)
269
+ return push plain(line.strip!(2)) if line.text[1] == SCRIPT
270
+ line.text = line.text[1..-1]
271
+ push script(line)
272
+ when FLAT_SCRIPT; push flat_script(line.strip!(1))
273
+ when SILENT_SCRIPT
274
+ return push haml_comment(line.text[2..-1]) if line.text[1] == SILENT_COMMENT
275
+ push silent_script(line)
276
+ when FILTER; push filter(line.text[1..-1].downcase)
227
277
  when DOCTYPE
228
- return push doctype(text) if text[0...3] == '!!!'
229
- return push plain(text[3..-1].strip, false) if text[1..2] == "=="
230
- return push script(text[2..-1].strip, false) if text[1] == SCRIPT
231
- return push flat_script(text[2..-1].strip, false) if text[1] == FLAT_SCRIPT
232
- return push plain(text[1..-1].strip, false) if text[1] == ?\s
233
- push plain(text)
234
- when ESCAPE; push plain(text[1..-1])
235
- else; push plain(text)
278
+ return push doctype(line.text) if line.text[0, 3] == '!!!'
279
+ return push plain(line.strip!(3), false) if line.text[1, 2] == '=='
280
+ return push script(line.strip!(2), false) if line.text[1] == SCRIPT
281
+ return push flat_script(line.strip!(2), false) if line.text[1] == FLAT_SCRIPT
282
+ return push plain(line.strip!(1), false) if line.text[1] == ?\s || line.text[1..2] == '#{'
283
+ push plain(line)
284
+ when ESCAPE
285
+ line.text = line.text[1..-1]
286
+ push plain(line)
287
+ else; push plain(line)
236
288
  end
237
289
  end
238
290
 
239
291
  def block_keyword(text)
240
- return unless keyword = text.scan(BLOCK_KEYWORD_REGEX)[0]
292
+ return unless (keyword = text.scan(BLOCK_KEYWORD_REGEX)[0])
241
293
  keyword[0] || keyword[1]
242
294
  end
243
295
 
244
- def mid_block_keyword?(text)
245
- MID_BLOCK_KEYWORDS.include?(block_keyword(text))
246
- end
247
-
248
296
  def push(node)
249
297
  @parent.children << node
250
298
  node.parent = @parent
251
299
  end
252
300
 
253
- def plain(text, escape_html = nil)
301
+ def plain(line, escape_html = nil)
254
302
  if block_opened?
255
303
  raise SyntaxError.new(Error.message(:illegal_nesting_plain), @next_line.index)
256
304
  end
257
305
 
258
- unless contains_interpolation?(text)
259
- return ParseNode.new(:plain, @index, :text => text)
306
+ unless contains_interpolation?(line.text)
307
+ return ParseNode.new(:plain, line.index + 1, :text => line.text)
260
308
  end
261
309
 
262
- escape_html = @options[:escape_html] if escape_html.nil?
263
- script(unescape_interpolation(text, escape_html), false)
310
+ escape_html = @options.escape_html if escape_html.nil?
311
+ line.text = unescape_interpolation(line.text, escape_html)
312
+ script(line, false)
264
313
  end
265
314
 
266
- def script(text, escape_html = nil, preserve = false)
267
- raise SyntaxError.new(Error.message(:no_ruby_code, '=')) if text.empty?
268
- text = handle_ruby_multiline(text)
269
- escape_html = @options[:escape_html] if escape_html.nil?
315
+ def script(line, escape_html = nil, preserve = false)
316
+ raise SyntaxError.new(Error.message(:no_ruby_code, '=')) if line.text.empty?
317
+ line = handle_ruby_multiline(line)
318
+ escape_html = @options.escape_html if escape_html.nil?
270
319
 
271
- keyword = block_keyword(text)
320
+ keyword = block_keyword(line.text)
272
321
  check_push_script_stack(keyword)
273
322
 
274
- ParseNode.new(:script, @index, :text => text, :escape_html => escape_html,
323
+ ParseNode.new(:script, line.index + 1, :text => line.text, :escape_html => escape_html,
275
324
  :preserve => preserve, :keyword => keyword)
276
325
  end
277
326
 
278
- def flat_script(text, escape_html = nil)
279
- raise SyntaxError.new(Error.message(:no_ruby_code, '~')) if text.empty?
280
- script(text, escape_html, :preserve)
327
+ def flat_script(line, escape_html = nil)
328
+ raise SyntaxError.new(Error.message(:no_ruby_code, '~')) if line.text.empty?
329
+ script(line, escape_html, :preserve)
281
330
  end
282
331
 
283
- def silent_script(text)
284
- return haml_comment(text[2..-1]) if text[1] == SILENT_COMMENT
285
-
286
- raise SyntaxError.new(Error.message(:no_end), @index - 1) if text[1..-1].strip == "end"
332
+ def silent_script(line)
333
+ raise SyntaxError.new(Error.message(:no_end), line.index) if line.text[1..-1].strip == 'end'
287
334
 
288
- text = handle_ruby_multiline(text)
289
- keyword = block_keyword(text)
335
+ line = handle_ruby_multiline(line)
336
+ keyword = block_keyword(line.text)
290
337
 
291
338
  check_push_script_stack(keyword)
292
339
 
@@ -308,8 +355,8 @@ module Haml
308
355
  end
309
356
  end
310
357
 
311
- ParseNode.new(:silent_script, @index,
312
- :text => text[1..-1], :keyword => keyword)
358
+ ParseNode.new(:silent_script, @line.index + 1,
359
+ :text => line.text[1..-1], :keyword => keyword)
313
360
  end
314
361
 
315
362
  def check_push_script_stack(keyword)
@@ -323,18 +370,25 @@ module Haml
323
370
  end
324
371
 
325
372
  def haml_comment(text)
326
- @haml_comment = block_opened?
327
- ParseNode.new(:haml_comment, @index, :text => text)
373
+ if filter_opened?
374
+ @flat = true
375
+ @filter_buffer = String.new
376
+ @filter_buffer << "#{text}\n" unless text.empty?
377
+ text = @filter_buffer
378
+ # If we don't know the indentation by now, it'll be set in Line#tabs
379
+ @flat_spaces = @indentation * (@template_tabs+1) if @indentation
380
+ end
381
+
382
+ ParseNode.new(:haml_comment, @line.index + 1, :text => text)
328
383
  end
329
384
 
330
385
  def tag(line)
331
386
  tag_name, attributes, attributes_hashes, object_ref, nuke_outer_whitespace,
332
- nuke_inner_whitespace, action, value, last_line = parse_tag(line)
387
+ nuke_inner_whitespace, action, value, last_line = parse_tag(line.text)
333
388
 
334
- preserve_tag = @options[:preserve].include?(tag_name)
389
+ preserve_tag = @options.preserve.include?(tag_name)
335
390
  nuke_inner_whitespace ||= preserve_tag
336
- preserve_tag = false if @options[:ugly]
337
- escape_html = (action == '&' || (action != '!' && @options[:escape_html]))
391
+ escape_html = (action == '&' || (action != '!' && @options.escape_html))
338
392
 
339
393
  case action
340
394
  when '/'; self_closing = true
@@ -369,22 +423,20 @@ module Haml
369
423
  end
370
424
 
371
425
  attributes = Parser.parse_class_and_id(attributes)
372
- attributes_list = []
426
+ dynamic_attributes = DynamicAttributes.new
373
427
 
374
428
  if attributes_hashes[:new]
375
429
  static_attributes, attributes_hash = attributes_hashes[:new]
376
- Buffer.merge_attrs(attributes, static_attributes) if static_attributes
377
- attributes_list << attributes_hash
430
+ AttributeBuilder.merge_attributes!(attributes, static_attributes) if static_attributes
431
+ dynamic_attributes.new = attributes_hash
378
432
  end
379
433
 
380
434
  if attributes_hashes[:old]
381
435
  static_attributes = parse_static_hash(attributes_hashes[:old])
382
- Buffer.merge_attrs(attributes, static_attributes) if static_attributes
383
- attributes_list << attributes_hashes[:old] unless static_attributes || @options[:suppress_eval]
436
+ AttributeBuilder.merge_attributes!(attributes, static_attributes) if static_attributes
437
+ dynamic_attributes.old = attributes_hashes[:old] unless static_attributes || @options.suppress_eval
384
438
  end
385
439
 
386
- attributes_list.compact!
387
-
388
440
  raise SyntaxError.new(Error.message(:illegal_nesting_self_closing), @next_line.index) if block_opened? && self_closing
389
441
  raise SyntaxError.new(Error.message(:no_ruby_code, action), last_line - 1) if parse && value.empty?
390
442
  raise SyntaxError.new(Error.message(:self_closing_content), last_line - 1) if self_closing && !value.empty?
@@ -393,56 +445,70 @@ module Haml
393
445
  raise SyntaxError.new(Error.message(:illegal_nesting_line, tag_name), @next_line.index)
394
446
  end
395
447
 
396
- self_closing ||= !!(!block_opened? && value.empty? && @options[:autoclose].any? {|t| t === tag_name})
448
+ self_closing ||= !!(!block_opened? && value.empty? && @options.autoclose.any? {|t| t === tag_name})
397
449
  value = nil if value.empty? && (block_opened? || self_closing)
398
- value = handle_ruby_multiline(value) if parse
450
+ line.text = value
451
+ line = handle_ruby_multiline(line) if parse
399
452
 
400
- ParseNode.new(:tag, @index, :name => tag_name, :attributes => attributes,
401
- :attributes_hashes => attributes_list, :self_closing => self_closing,
453
+ ParseNode.new(:tag, line.index + 1, :name => tag_name, :attributes => attributes,
454
+ :dynamic_attributes => dynamic_attributes, :self_closing => self_closing,
402
455
  :nuke_inner_whitespace => nuke_inner_whitespace,
403
456
  :nuke_outer_whitespace => nuke_outer_whitespace, :object_ref => object_ref,
404
457
  :escape_html => escape_html, :preserve_tag => preserve_tag,
405
- :preserve_script => preserve_script, :parse => parse, :value => value)
458
+ :preserve_script => preserve_script, :parse => parse, :value => line.text)
406
459
  end
407
460
 
408
461
  # Renders a line that creates an XHTML tag and has an implicit div because of
409
462
  # `.` or `#`.
410
463
  def div(line)
411
- tag('%div' + line)
464
+ line.text = "%div#{line.text}"
465
+ tag(line)
412
466
  end
413
467
 
414
468
  # Renders an XHTML comment.
415
- def comment(line)
416
- conditional, line = balance(line, ?[, ?]) if line[0] == ?[
417
- line.strip!
418
- conditional << ">" if conditional
469
+ def comment(text)
470
+ if text[0..1] == '!['
471
+ revealed = true
472
+ text = text[1..-1]
473
+ else
474
+ revealed = false
475
+ end
419
476
 
420
- if block_opened? && !line.empty?
477
+ conditional, text = balance(text, ?[, ?]) if text[0] == ?[
478
+ text.strip!
479
+
480
+ if contains_interpolation?(text)
481
+ parse = true
482
+ text = unescape_interpolation(text)
483
+ else
484
+ parse = false
485
+ end
486
+
487
+ if block_opened? && !text.empty?
421
488
  raise SyntaxError.new(Haml::Error.message(:illegal_nesting_content), @next_line.index)
422
489
  end
423
490
 
424
- ParseNode.new(:comment, @index, :conditional => conditional, :text => line)
491
+ ParseNode.new(:comment, @line.index + 1, :conditional => conditional, :text => text, :revealed => revealed, :parse => parse)
425
492
  end
426
493
 
427
494
  # Renders an XHTML doctype or XML shebang.
428
- def doctype(line)
495
+ def doctype(text)
429
496
  raise SyntaxError.new(Error.message(:illegal_nesting_header), @next_line.index) if block_opened?
430
- version, type, encoding = line[3..-1].strip.downcase.scan(DOCTYPE_REGEX)[0]
431
- ParseNode.new(:doctype, @index, :version => version, :type => type, :encoding => encoding)
497
+ version, type, encoding = text[3..-1].strip.downcase.scan(DOCTYPE_REGEX)[0]
498
+ ParseNode.new(:doctype, @line.index + 1, :version => version, :type => type, :encoding => encoding)
432
499
  end
433
500
 
434
501
  def filter(name)
435
502
  raise Error.new(Error.message(:invalid_filter_name, name)) unless name =~ /^\w+$/
436
503
 
437
- @filter_buffer = String.new
438
-
439
504
  if filter_opened?
440
505
  @flat = true
506
+ @filter_buffer = String.new
441
507
  # If we don't know the indentation by now, it'll be set in Line#tabs
442
508
  @flat_spaces = @indentation * (@template_tabs+1) if @indentation
443
509
  end
444
510
 
445
- ParseNode.new(:filter, @index, :name => name, :text => @filter_buffer)
511
+ ParseNode.new(:filter, @line.index + 1, :name => name, :text => @filter_buffer)
446
512
  end
447
513
 
448
514
  def close
@@ -452,13 +518,17 @@ module Haml
452
518
  end
453
519
 
454
520
  def close_filter(_)
455
- @flat = false
456
- @flat_spaces = nil
457
- @filter_buffer = nil
521
+ close_flat_section
458
522
  end
459
523
 
460
524
  def close_haml_comment(_)
461
- @haml_comment = false
525
+ close_flat_section
526
+ end
527
+
528
+ def close_flat_section
529
+ @flat = false
530
+ @flat_spaces = nil
531
+ @filter_buffer = nil
462
532
  end
463
533
 
464
534
  def close_silent_script(node)
@@ -466,7 +536,7 @@ module Haml
466
536
 
467
537
  # Post-process case statements to normalize the nesting of "when" clauses
468
538
  return unless node.value[:keyword] == "case"
469
- return unless first = node.children.first
539
+ return unless (first = node.children.first)
470
540
  return unless first.type == :silent_script && first.value[:keyword] == "when"
471
541
  return if first.children.empty?
472
542
  # If the case node has a "when" child with children, it's the
@@ -485,29 +555,39 @@ module Haml
485
555
  # that can then be merged with another attributes hash.
486
556
  def self.parse_class_and_id(list)
487
557
  attributes = {}
488
- list.scan(/([#.])([-:_a-zA-Z0-9]+)/) do |type, property|
558
+ return attributes if list.empty?
559
+
560
+ list.scan(/([#.])([-:_a-zA-Z0-9\@]+)/) do |type, property|
489
561
  case type
490
562
  when '.'
491
- if attributes['class']
492
- attributes['class'] += " "
563
+ if attributes[CLASS_KEY]
564
+ attributes[CLASS_KEY] += " "
493
565
  else
494
- attributes['class'] = ""
566
+ attributes[CLASS_KEY] = ""
495
567
  end
496
- attributes['class'] += property
497
- when '#'; attributes['id'] = property
568
+ attributes[CLASS_KEY] += property
569
+ when '#'; attributes[ID_KEY] = property
498
570
  end
499
571
  end
500
572
  attributes
501
573
  end
502
574
 
575
+ # This method doesn't use Haml::AttributeParser because currently it depends on Ripper and Rubinius doesn't provide it.
576
+ # Ideally this logic should be placed in Haml::AttributeParser instead of here and this method should use it.
577
+ #
578
+ # @param [String] text - Hash literal or text inside old attributes
579
+ # @return [Hash,nil] - Return nil if text is not static Hash literal
503
580
  def parse_static_hash(text)
504
581
  attributes = {}
582
+ return attributes if text.empty?
583
+
584
+ text = text[1...-1] # strip brackets
505
585
  scanner = StringScanner.new(text)
506
586
  scanner.scan(/\s+/)
507
587
  until scanner.eos?
508
- return unless key = scanner.scan(LITERAL_VALUE_REGEX)
588
+ return unless (key = scanner.scan(LITERAL_VALUE_REGEX))
509
589
  return unless scanner.scan(/\s*=>\s*/)
510
- return unless value = scanner.scan(LITERAL_VALUE_REGEX)
590
+ return unless (value = scanner.scan(LITERAL_VALUE_REGEX))
511
591
  return unless scanner.scan(/\s*(?:,|$)\s*/)
512
592
  attributes[eval(key).to_s] = eval(value).to_s
513
593
  end
@@ -515,20 +595,20 @@ module Haml
515
595
  end
516
596
 
517
597
  # Parses a line into tag_name, attributes, attributes_hash, object_ref, action, value
518
- def parse_tag(line)
519
- match = line.scan(/%([-:\w]+)([-:\w\.\#]*)(.*)/)[0]
520
- raise SyntaxError.new(Error.message(:invalid_tag, line)) unless match
598
+ def parse_tag(text)
599
+ match = text.scan(/%([-:\w]+)([-:\w.#\@]*)(.+)?/)[0]
600
+ raise SyntaxError.new(Error.message(:invalid_tag, text)) unless match
521
601
 
522
602
  tag_name, attributes, rest = match
523
603
 
524
- if attributes =~ /[\.#](\.|#|\z)/
604
+ if !attributes.empty? && (attributes =~ /[.#](\.|#|\z)/)
525
605
  raise SyntaxError.new(Error.message(:illegal_element))
526
606
  end
527
607
 
528
608
  new_attributes_hash = old_attributes_hash = last_line = nil
529
- object_ref = "nil"
609
+ object_ref = :nil
530
610
  attributes_hashes = {}
531
- while rest
611
+ while rest && !rest.empty?
532
612
  case rest[0]
533
613
  when ?{
534
614
  break if old_attributes_hash
@@ -539,38 +619,46 @@ module Haml
539
619
  new_attributes_hash, rest, last_line = parse_new_attributes(rest)
540
620
  attributes_hashes[:new] = new_attributes_hash
541
621
  when ?[
542
- break unless object_ref == "nil"
622
+ break unless object_ref == :nil
543
623
  object_ref, rest = balance(rest, ?[, ?])
544
624
  else; break
545
625
  end
546
626
  end
547
627
 
548
- if rest
628
+ if rest && !rest.empty?
549
629
  nuke_whitespace, action, value = rest.scan(/(<>|><|[><])?([=\/\~&!])?(.*)?/)[0]
550
- nuke_whitespace ||= ''
551
- nuke_outer_whitespace = nuke_whitespace.include? '>'
552
- nuke_inner_whitespace = nuke_whitespace.include? '<'
630
+ if nuke_whitespace
631
+ nuke_outer_whitespace = nuke_whitespace.include? '>'
632
+ nuke_inner_whitespace = nuke_whitespace.include? '<'
633
+ end
553
634
  end
554
635
 
555
- if @options[:remove_whitespace]
636
+ if @options.remove_whitespace
556
637
  nuke_outer_whitespace = true
557
638
  nuke_inner_whitespace = true
558
639
  end
559
640
 
560
- value = value.to_s.strip
641
+ if value.nil?
642
+ value = ''
643
+ else
644
+ value.strip!
645
+ end
561
646
  [tag_name, attributes, attributes_hashes, object_ref, nuke_outer_whitespace,
562
- nuke_inner_whitespace, action, value, last_line || @index]
647
+ nuke_inner_whitespace, action, value, last_line || @line.index + 1]
563
648
  end
564
649
 
565
- def parse_old_attributes(line)
566
- line = line.dup
567
- last_line = @index
650
+ # @return [String] attributes_hash - Hash literal starting with `{` and ending with `}`
651
+ # @return [String] rest
652
+ # @return [Integer] last_line
653
+ def parse_old_attributes(text)
654
+ text = text.dup
655
+ last_line = @line.index + 1
568
656
 
569
657
  begin
570
- attributes_hash, rest = balance(line, ?{, ?})
658
+ attributes_hash, rest = balance(text, ?{, ?})
571
659
  rescue SyntaxError => e
572
- if line.strip[-1] == ?, && e.message == Error.message(:unbalanced_brackets)
573
- line << "\n" << @next_line.text
660
+ if text.strip[-1] == ?, && e.message == Error.message(:unbalanced_brackets)
661
+ text << "\n#{@next_line.text}"
574
662
  last_line += 1
575
663
  next_line
576
664
  retry
@@ -579,14 +667,15 @@ module Haml
579
667
  raise e
580
668
  end
581
669
 
582
- attributes_hash = attributes_hash[1...-1] if attributes_hash
583
670
  return attributes_hash, rest, last_line
584
671
  end
585
672
 
586
- def parse_new_attributes(line)
587
- line = line.dup
588
- scanner = StringScanner.new(line)
589
- last_line = @index
673
+ # @return [Array<Hash,String,nil>] - [static_attributes (Hash), dynamic_attributes (nil or String starting with `{` and ending with `}`)]
674
+ # @return [String] rest
675
+ # @return [Integer] last_line
676
+ def parse_new_attributes(text)
677
+ scanner = StringScanner.new(text)
678
+ last_line = @line.index + 1
590
679
  attributes = {}
591
680
 
592
681
  scanner.scan(/\(\s*/)
@@ -595,14 +684,15 @@ module Haml
595
684
  break if name.nil?
596
685
 
597
686
  if name == false
598
- text = (Haml::Util.balance(line, ?(, ?)) || [line]).first
687
+ scanned = Haml::Util.balance(text, ?(, ?))
688
+ text = scanned ? scanned.first : text
599
689
  raise Haml::SyntaxError.new(Error.message(:invalid_attribute_list, text.inspect), last_line - 1)
600
690
  end
601
691
  attributes[name] = value
602
692
  scanner.scan(/\s*/)
603
693
 
604
694
  if scanner.eos?
605
- line << " " << @next_line.text
695
+ text << " #{@next_line.text}"
606
696
  last_line += 1
607
697
  next_line
608
698
  scanner.scan(/\s*/)
@@ -610,12 +700,12 @@ module Haml
610
700
  end
611
701
 
612
702
  static_attributes = {}
613
- dynamic_attributes = "{"
703
+ dynamic_attributes = "{".dup
614
704
  attributes.each do |name, (type, val)|
615
705
  if type == :static
616
706
  static_attributes[name] = val
617
707
  else
618
- dynamic_attributes << inspect_obj(name) << " => " << val << ","
708
+ dynamic_attributes << "#{inspect_obj(name)} => #{val},"
619
709
  end
620
710
  end
621
711
  dynamic_attributes << "}"
@@ -625,7 +715,7 @@ module Haml
625
715
  end
626
716
 
627
717
  def parse_new_attribute(scanner)
628
- unless name = scanner.scan(/[-:\w]+/)
718
+ unless (name = scanner.scan(/[-:\w]+/))
629
719
  return if scanner.scan(/\)/)
630
720
  return false
631
721
  end
@@ -634,8 +724,8 @@ module Haml
634
724
  return name, [:static, true] unless scanner.scan(/=/) #/end
635
725
 
636
726
  scanner.scan(/\s*/)
637
- unless quote = scanner.scan(/["']/)
638
- return false unless var = scanner.scan(/(@@?|\$)?\w+/)
727
+ unless (quote = scanner.scan(/["']/))
728
+ return false unless (var = scanner.scan(/(@@?|\$)?\w+/))
639
729
  return name, [:dynamic, var]
640
730
  end
641
731
 
@@ -650,35 +740,16 @@ module Haml
650
740
 
651
741
  return name, [:static, content.first[1]] if content.size == 1
652
742
  return name, [:dynamic,
653
- '"' + content.map {|(t, v)| t == :str ? inspect_obj(v)[1...-1] : "\#{#{v}}"}.join + '"']
654
- end
655
-
656
- def raw_next_line
657
- text = @template.shift
658
- return unless text
659
-
660
- index = @template_index
661
- @template_index += 1
662
-
663
- return text, index
743
+ %!"#{content.each_with_object(''.dup) {|(t, v), s| s << (t == :str ? inspect_obj(v)[1...-1] : "\#{#{v}}")}}"!]
664
744
  end
665
745
 
666
746
  def next_line
667
- text, index = raw_next_line
668
- return unless text
669
-
670
- # :eod is a special end-of-document marker
671
- line =
672
- if text == :eod
673
- Line.new '-#', '-#', '-#', index, self, true
674
- else
675
- Line.new text.strip, text.lstrip.chomp, text, index, self, false
676
- end
747
+ line = @template.shift || raise(StopIteration)
677
748
 
678
749
  # `flat?' here is a little outdated,
679
750
  # so we have to manually check if either the previous or current line
680
751
  # closes the flat block, as well as whether a new block is opened.
681
- line_defined = instance_variable_defined?('@line')
752
+ line_defined = instance_variable_defined?(:@line)
682
753
  @line.tabs if line_defined
683
754
  unless (flat? && !closes_flat?(line) && !closes_flat?(@line)) ||
684
755
  (line_defined && @line.text[0] == ?: && line.full =~ %r[^#{@line.full[/^\s+/]}\s])
@@ -694,21 +765,17 @@ module Haml
694
765
  line && !line.text.empty? && line.full !~ /^#{@flat_spaces}/
695
766
  end
696
767
 
697
- def un_next_line(line)
698
- @template.unshift line
699
- @template_index -= 1
700
- end
701
-
702
768
  def handle_multiline(line)
703
769
  return unless is_multiline?(line.text)
704
770
  line.text.slice!(-1)
705
- while new_line = raw_next_line.first
706
- break if new_line == :eod
707
- next if new_line.strip.empty?
708
- break unless is_multiline?(new_line.strip)
709
- line.text << new_line.strip[0...-1]
771
+ loop do
772
+ new_line = @template.first
773
+ break if new_line.eod?
774
+ next @template.shift if new_line.text.strip.empty?
775
+ break unless is_multiline?(new_line.text.strip)
776
+ line.text << new_line.text.strip[0...-1]
777
+ @template.shift
710
778
  end
711
- un_next_line new_line
712
779
  end
713
780
 
714
781
  # Checks whether or not `line` is in a multiline sequence.
@@ -716,18 +783,18 @@ module Haml
716
783
  text && text.length > 1 && text[-1] == MULTILINE_CHAR_VALUE && text[-2] == ?\s && text !~ BLOCK_WITH_SPACES
717
784
  end
718
785
 
719
- def handle_ruby_multiline(text)
720
- text = text.rstrip
721
- return text unless is_ruby_multiline?(text)
722
- un_next_line @next_line.full
786
+ def handle_ruby_multiline(line)
787
+ line.text.rstrip!
788
+ return line unless is_ruby_multiline?(line.text)
723
789
  begin
724
- new_line = raw_next_line.first
725
- break if new_line == :eod
726
- next if new_line.strip.empty?
727
- text << " " << new_line.strip
728
- end while is_ruby_multiline?(new_line.strip)
790
+ # Use already fetched @next_line in the first loop. Otherwise, fetch next
791
+ new_line = new_line.nil? ? @next_line : @template.shift
792
+ break if new_line.eod?
793
+ next if new_line.text.empty?
794
+ line.text << " #{new_line.text.rstrip}"
795
+ end while is_ruby_multiline?(new_line.text)
729
796
  next_line
730
- text
797
+ line
731
798
  end
732
799
 
733
800
  # `text' is a Ruby multiline block if it:
@@ -735,16 +802,13 @@ module Haml
735
802
  # - but not "?," which is a character literal
736
803
  # (however, "x?," is a method call and not a literal)
737
804
  # - and not "?\," which is a character literal
738
- #
739
805
  def is_ruby_multiline?(text)
740
806
  text && text.length > 1 && text[-1] == ?, &&
741
- !((text[-3..-2] =~ /\W\?/) || text[-3..-2] == "?\\")
807
+ !((text[-3, 2] =~ /\W\?/) || text[-3, 2] == "?\\")
742
808
  end
743
809
 
744
810
  def balance(*args)
745
- res = Haml::Util.balance(*args)
746
- return res if res
747
- raise SyntaxError.new(Error.message(:unbalanced_brackets))
811
+ Haml::Util.balance(*args) or raise(SyntaxError.new(Error.message(:unbalanced_brackets)))
748
812
  end
749
813
 
750
814
  def block_opened?
@@ -754,7 +818,7 @@ module Haml
754
818
  # Same semantics as block_opened?, except that block_opened? uses Line#tabs,
755
819
  # which doesn't interact well with filter lines
756
820
  def filter_opened?
757
- @next_line.full =~ (@indentation ? /^#{@indentation * @template_tabs}/ : /^\s/)
821
+ @next_line.full =~ (@indentation ? /^#{@indentation * (@template_tabs + 1)}/ : /^\s/)
758
822
  end
759
823
 
760
824
  def flat?