brakeman 4.8.0 → 4.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +39 -1
  3. data/README.md +12 -4
  4. data/bundle/load.rb +4 -4
  5. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/History.rdoc +35 -0
  6. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/Manifest.txt +2 -0
  7. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/README.rdoc +0 -0
  8. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/compare/normalize.rb +43 -3
  9. data/bundle/ruby/2.7.0/gems/ruby_parser-3.15.0/debugging.md +57 -0
  10. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/lib/rp_extensions.rb +0 -0
  11. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/lib/rp_stringscanner.rb +0 -0
  12. data/bundle/ruby/2.7.0/gems/ruby_parser-3.15.0/lib/ruby20_parser.rb +7062 -0
  13. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/lib/ruby20_parser.y +91 -58
  14. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/lib/ruby21_parser.rb +2603 -2576
  15. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/lib/ruby21_parser.y +91 -58
  16. data/bundle/ruby/2.7.0/gems/ruby_parser-3.15.0/lib/ruby22_parser.rb +7160 -0
  17. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/lib/ruby22_parser.y +91 -58
  18. data/bundle/ruby/2.7.0/gems/ruby_parser-3.15.0/lib/ruby23_parser.rb +7175 -0
  19. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/lib/ruby23_parser.y +91 -58
  20. data/bundle/ruby/2.7.0/gems/ruby_parser-3.15.0/lib/ruby24_parser.rb +7204 -0
  21. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/lib/ruby24_parser.y +91 -58
  22. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2/lib/ruby23_parser.rb → ruby_parser-3.15.0/lib/ruby25_parser.rb} +2867 -2826
  23. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/lib/ruby25_parser.y +91 -58
  24. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2/lib/ruby25_parser.rb → ruby_parser-3.15.0/lib/ruby26_parser.rb} +2432 -2383
  25. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/lib/ruby26_parser.y +91 -58
  26. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2/lib/ruby24_parser.rb → ruby_parser-3.15.0/lib/ruby27_parser.rb} +2432 -2383
  27. data/bundle/ruby/2.7.0/gems/ruby_parser-3.15.0/lib/ruby27_parser.y +2657 -0
  28. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/lib/ruby_lexer.rb +72 -40
  29. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/lib/ruby_lexer.rex +5 -6
  30. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/lib/ruby_lexer.rex.rb +6 -8
  31. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/lib/ruby_parser.rb +2 -0
  32. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/lib/ruby_parser.yy +93 -58
  33. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/lib/ruby_parser_extras.rb +49 -16
  34. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/tools/munge.rb +9 -4
  35. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.15.0}/tools/ripper.rb +0 -0
  36. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.15.1}/History.rdoc +12 -0
  37. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.15.1}/Manifest.txt +0 -0
  38. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.15.1}/README.rdoc +0 -0
  39. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.15.1}/lib/composite_sexp_processor.rb +0 -0
  40. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.15.1}/lib/pt_testcase.rb +2 -2
  41. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.15.1}/lib/sexp.rb +0 -0
  42. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.15.1}/lib/sexp_matcher.rb +4 -7
  43. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.15.1}/lib/sexp_processor.rb +1 -1
  44. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.15.1}/lib/strict_sexp.rb +0 -0
  45. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.15.1}/lib/unique.rb +0 -0
  46. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/CHANGES +4 -0
  47. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/Gemfile +12 -13
  48. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/LICENSE +0 -0
  49. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/README.jp.md +0 -0
  50. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/README.md +0 -0
  51. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim.rb +0 -0
  52. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/code_attributes.rb +0 -0
  53. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/command.rb +13 -13
  54. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/controls.rb +0 -0
  55. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/do_inserter.rb +0 -0
  56. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/embedded.rb +0 -0
  57. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/end_inserter.rb +0 -0
  58. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/engine.rb +0 -0
  59. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/erb_converter.rb +0 -0
  60. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/filter.rb +0 -0
  61. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/grammar.rb +0 -0
  62. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/include.rb +0 -0
  63. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/interpolation.rb +0 -0
  64. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/logic_less.rb +0 -0
  65. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/logic_less/context.rb +0 -0
  66. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/logic_less/filter.rb +0 -0
  67. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/parser.rb +1 -1
  68. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/smart.rb +0 -0
  69. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/smart/escaper.rb +0 -0
  70. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/smart/filter.rb +0 -0
  71. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/smart/parser.rb +0 -0
  72. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/splat/builder.rb +0 -0
  73. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/splat/filter.rb +0 -0
  74. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/template.rb +0 -0
  75. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/translator.rb +0 -0
  76. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/version.rb +1 -1
  77. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/slim.gemspec +0 -0
  78. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.7.0}/CHANGELOG.md +4 -0
  79. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.7.0}/MIT-LICENSE.txt +0 -0
  80. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.7.0}/README.md +1 -1
  81. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.7.0/data/display_width.marshal.gz +0 -0
  82. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.7.0}/lib/unicode/display_width.rb +0 -0
  83. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.7.0}/lib/unicode/display_width/constants.rb +2 -2
  84. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.7.0}/lib/unicode/display_width/index.rb +0 -0
  85. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.7.0}/lib/unicode/display_width/no_string_ext.rb +0 -0
  86. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.7.0}/lib/unicode/display_width/string_ext.rb +0 -0
  87. data/lib/brakeman.rb +20 -0
  88. data/lib/brakeman/checks/base_check.rb +1 -1
  89. data/lib/brakeman/checks/check_basic_auth.rb +2 -0
  90. data/lib/brakeman/checks/check_csrf_token_forgery_cve.rb +28 -0
  91. data/lib/brakeman/checks/check_deserialize.rb +21 -1
  92. data/lib/brakeman/checks/check_json_entity_escape.rb +38 -0
  93. data/lib/brakeman/checks/check_mass_assignment.rb +33 -3
  94. data/lib/brakeman/checks/check_model_attr_accessible.rb +1 -1
  95. data/lib/brakeman/checks/check_model_attributes.rb +1 -1
  96. data/lib/brakeman/checks/check_page_caching_cve.rb +37 -0
  97. data/lib/brakeman/checks/check_permit_attributes.rb +1 -1
  98. data/lib/brakeman/checks/check_skip_before_filter.rb +4 -4
  99. data/lib/brakeman/checks/check_sql.rb +1 -1
  100. data/lib/brakeman/checks/check_template_injection.rb +32 -0
  101. data/lib/brakeman/commandline.rb +25 -1
  102. data/lib/brakeman/options.rb +21 -1
  103. data/lib/brakeman/processors/alias_processor.rb +2 -3
  104. data/lib/brakeman/processors/lib/call_conversion_helper.rb +1 -1
  105. data/lib/brakeman/processors/lib/find_all_calls.rb +28 -13
  106. data/lib/brakeman/processors/lib/render_helper.rb +3 -1
  107. data/lib/brakeman/report.rb +7 -0
  108. data/lib/brakeman/report/ignore/config.rb +4 -0
  109. data/lib/brakeman/report/report_sarif.rb +114 -0
  110. data/lib/brakeman/report/report_text.rb +37 -16
  111. data/lib/brakeman/scanner.rb +4 -1
  112. data/lib/brakeman/tracker.rb +3 -1
  113. data/lib/brakeman/tracker/config.rb +6 -4
  114. data/lib/brakeman/tracker/constants.rb +8 -7
  115. data/lib/brakeman/util.rb +16 -0
  116. data/lib/brakeman/version.rb +1 -1
  117. data/lib/brakeman/warning_codes.rb +7 -0
  118. metadata +89 -82
  119. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/debugging.md +0 -18
  120. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/ruby20_parser.rb +0 -7042
  121. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/ruby22_parser.rb +0 -7146
  122. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/ruby26_parser.rb +0 -7195
  123. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.6.1/data/display_width.marshal.gz +0 -0
@@ -1,4 +1,5 @@
1
1
  # encoding: ASCII-8BIT
2
+ # TODO: remove
2
3
 
3
4
  require "sexp"
4
5
  require "ruby_lexer"
@@ -28,7 +29,7 @@ class Sexp
28
29
  end
29
30
 
30
31
  module RubyParserStuff
31
- VERSION = "3.14.2"
32
+ VERSION = "3.15.0"
32
33
 
33
34
  attr_accessor :lexer, :in_def, :in_single, :file
34
35
  attr_accessor :in_kwarg
@@ -45,6 +46,11 @@ module RubyParserStuff
45
46
 
46
47
  attr_accessor :canonicalize_conditions
47
48
 
49
+ ##
50
+ # The last token type returned from #next_token
51
+
52
+ attr_accessor :last_token_type
53
+
48
54
  $good20 = []
49
55
 
50
56
  %w[
@@ -493,6 +499,8 @@ module RubyParserStuff
493
499
  str.encode! Encoding::UTF_8
494
500
  break
495
501
  end
502
+ rescue ArgumentError # unknown encoding name
503
+ # do nothing
496
504
  rescue Encoding::InvalidByteSequenceError
497
505
  # do nothing
498
506
  rescue Encoding::UndefinedConversionError
@@ -532,7 +540,7 @@ module RubyParserStuff
532
540
  header.map! { |s| s.force_encoding "ASCII-8BIT" } if has_enc
533
541
 
534
542
  first = header.first || ""
535
- encoding, str = "utf-8", str[3..-1] if first =~ /\A\xEF\xBB\xBF/
543
+ encoding, str = "utf-8", str.b[3..-1] if first =~ /\A\xEF\xBB\xBF/
536
544
 
537
545
  encoding = $1.strip if header.find { |s|
538
546
  s[/^#.*?-\*-.*?coding:\s*([^ ;]+).*?-\*-/, 1] ||
@@ -592,7 +600,9 @@ module RubyParserStuff
592
600
  case ttype
593
601
  when :str then
594
602
  if htype == :str
595
- head.last << tail.last
603
+ a, b = head.last, tail.last
604
+ b = b.dup.force_encoding a.encoding unless Encoding.compatible?(a, b)
605
+ a << b
596
606
  elsif htype == :dstr and head.size == 2 then
597
607
  head.last << tail.last
598
608
  else
@@ -696,6 +706,15 @@ module RubyParserStuff
696
706
  result
697
707
  end
698
708
 
709
+ def new_begin val
710
+ _, lineno, body, _ = val
711
+
712
+ result = body ? s(:begin, body) : s(:nil)
713
+ result.line lineno
714
+
715
+ result
716
+ end
717
+
699
718
  def new_body val
700
719
  body, resbody, elsebody, ensurebody = val
701
720
 
@@ -723,7 +742,10 @@ module RubyParserStuff
723
742
  result = block_append(result, elsebody)
724
743
  end
725
744
 
726
- result = s(:ensure, result, ensurebody).compact.line result.line if ensurebody
745
+ if ensurebody
746
+ lineno = (result || ensurebody).line
747
+ result = s(:ensure, result, ensurebody).compact.line lineno
748
+ end
727
749
 
728
750
  result
729
751
  end
@@ -843,14 +865,17 @@ module RubyParserStuff
843
865
  end
844
866
 
845
867
  def new_defs val
846
- recv, (name, _line), args, body = val[1], val[4], val[6], val[7]
847
- line, _ = val[5]
868
+ _, recv, _, _, name, (_in_def, line), args, body, _ = val
869
+
848
870
  body ||= s(:nil).line line
849
871
 
850
872
  args.line line
851
873
 
852
874
  result = s(:defs, recv, name.to_sym, args)
853
875
 
876
+ # TODO: remove_begin
877
+ # TODO: reduce_nodes
878
+
854
879
  if body then
855
880
  if body.sexp_type == :block then
856
881
  result.push(*body.sexp_body)
@@ -875,7 +900,9 @@ module RubyParserStuff
875
900
  end
876
901
 
877
902
  def new_hash val
878
- s(:hash, *val[2].values).line(val[1])
903
+ _, line, assocs = val
904
+
905
+ s(:hash).line(line).concat assocs.values
879
906
  end
880
907
 
881
908
  def new_if c, t, f
@@ -1134,6 +1161,7 @@ module RubyParserStuff
1134
1161
  def new_string val
1135
1162
  str, = val
1136
1163
  str.force_encoding("UTF-8")
1164
+ # TODO: remove:
1137
1165
  str.force_encoding("ASCII-8BIT") unless str.valid_encoding?
1138
1166
  result = s(:str, str).line lexer.lineno
1139
1167
  self.lexer.fixup_lineno str.count("\n")
@@ -1228,20 +1256,23 @@ module RubyParserStuff
1228
1256
  result
1229
1257
  end
1230
1258
 
1231
- def new_xstring str
1232
- if str then
1233
- case str.sexp_type
1259
+ def new_xstring val
1260
+ _, node = val
1261
+
1262
+ node ||= s(:str, "").line lexer.lineno
1263
+
1264
+ if node then
1265
+ case node.sexp_type
1234
1266
  when :str
1235
- str.sexp_type = :xstr
1267
+ node.sexp_type = :xstr
1236
1268
  when :dstr
1237
- str.sexp_type = :dxstr
1269
+ node.sexp_type = :dxstr
1238
1270
  else
1239
- str = s(:dxstr, "", str).line str.line
1271
+ node = s(:dxstr, "", node).line node.line
1240
1272
  end
1241
- str
1242
- else
1243
- s(:xstr, "")
1244
1273
  end
1274
+
1275
+ node
1245
1276
  end
1246
1277
 
1247
1278
  def new_yield args = nil
@@ -1262,6 +1293,7 @@ module RubyParserStuff
1262
1293
  token = self.lexer.next_token
1263
1294
 
1264
1295
  if token and token.first != RubyLexer::EOF then
1296
+ self.last_token_type = token
1265
1297
  return token
1266
1298
  else
1267
1299
  return [false, false]
@@ -1320,6 +1352,7 @@ module RubyParserStuff
1320
1352
  self.in_single = 0
1321
1353
  self.env.reset
1322
1354
  self.comments.clear
1355
+ self.last_token_type = nil
1323
1356
  end
1324
1357
 
1325
1358
  def ret_args node
@@ -1,4 +1,4 @@
1
- #!/usr/bin/ruby -ws
1
+ #!/usr/bin/env ruby -ws
2
2
 
3
3
  $v ||= false
4
4
 
@@ -118,6 +118,8 @@ def munge s
118
118
 
119
119
  /@(\d+)(\s+|$)/, "",
120
120
  /\$?@(\d+) */, "", # TODO: remove?
121
+
122
+ /_EXPR/, "",
121
123
  ]
122
124
 
123
125
  renames.each_slice(2) do |(a, b)|
@@ -194,10 +196,13 @@ ARGF.each_line do |line|
194
196
  # TODO: make pretty, but still informative w/ line numbers etc
195
197
  puts line.gsub("true", "1").gsub("false", "0")
196
198
  when /^lex_state: :?([\w|]+) -> :?([\w|]+)(?: (?:at|from) (.*))?/ then
197
- if $3 && $v then
198
- puts "lex_state: #{$1.upcase} -> #{$2.upcase} at #{$3}"
199
+ a, b, c = $1.upcase, $2.upcase, $3
200
+ a.gsub! /EXPR_/, ""
201
+ b.gsub! /EXPR_/, ""
202
+ if c && $v then
203
+ puts "lex_state: #{a} -> #{b} at #{c}"
199
204
  else
200
- puts "lex_state: #{$1.upcase} -> #{$2.upcase}"
205
+ puts "lex_state: #{a} -> #{b}"
201
206
  end
202
207
  when /debug|FUCK/ then
203
208
  puts line.chomp
@@ -1,3 +1,15 @@
1
+ === 4.15.1 / 2020-08-31
2
+
3
+ * 1 bug fix:
4
+
5
+ * Bumped ruby version to include 3.0 (trunk).
6
+
7
+ === 4.15.0 / 2020-06-09
8
+
9
+ * 1 minor enhancement:
10
+
11
+ * Added `child` and `include` to Sexp::Matcher.parse language.
12
+
1
13
  === 4.14.1 / 2020-02-09
2
14
 
3
15
  * 2 bug fixes:
@@ -77,7 +77,7 @@ class ParseTreeTestCase < Minitest::Test
77
77
  end
78
78
 
79
79
  def self.add_19tests name, hash
80
- add_tests "#{name}__19_20_21_22_23_24_25_26", hash # HACK?
80
+ add_tests "#{name}__19_20_21_22_23_24_25_26_27", hash # HACK?
81
81
  end
82
82
 
83
83
  def self.add_19edgecases ruby, sexp, cases
@@ -102,7 +102,7 @@ class ParseTreeTestCase < Minitest::Test
102
102
  testcases[verbose][klass] = testcases[nonverbose][klass]
103
103
  end
104
104
 
105
- VER_RE = "(1[89]|2[0123456])"
105
+ VER_RE = "(1[89]|2[01234567])"
106
106
 
107
107
  def self.generate_test klass, node, data, input_name, output_name
108
108
  klass.send :define_method, "test_#{node}" do
@@ -455,7 +455,7 @@ class Sexp #:nodoc:
455
455
  # | NAME:name => name.to_sym
456
456
  # UP_NAME: /[A-Z]\w*/
457
457
  # NAME : /:?[\w?!=~-]+/
458
- # CMD : "t" | "k" | "m" | "atom" | "not?" | "-" | "any"
458
+ # CMD : t | k | m | atom | not? | - | any | child | include
459
459
 
460
460
  def parse_sexp
461
461
  token = next_token
@@ -505,7 +505,7 @@ class Sexp #:nodoc:
505
505
  ##
506
506
  # A collection of allowed commands to convert into matchers.
507
507
 
508
- ALLOWED = [:t, :m, :k, :atom, :not?, :-, :any].freeze
508
+ ALLOWED = [:t, :m, :k, :atom, :not?, :-, :any, :child, :include].freeze
509
509
 
510
510
  ##
511
511
  # Parses a balanced command. A command is denoted by square
@@ -760,11 +760,8 @@ class Sexp #:nodoc:
760
760
  # +child+.
761
761
 
762
762
  def satisfy? o
763
- if child.satisfy? o
764
- true
765
- elsif o.kind_of? Sexp
766
- o.search_each(child).any?
767
- end
763
+ child.satisfy?(o) ||
764
+ (o.kind_of?(Sexp) && o.search_each(child).any?)
768
765
  end
769
766
 
770
767
  def == o # :nodoc:
@@ -34,7 +34,7 @@ require "sexp"
34
34
  class SexpProcessor
35
35
 
36
36
  # duh
37
- VERSION = "4.14.1"
37
+ VERSION = "4.15.1"
38
38
 
39
39
  ##
40
40
  # Automatically shifts off the Sexp type before handing the
@@ -1,3 +1,7 @@
1
+ 4.1.0 (2020-05-07)
2
+ * Add support for Tailwind CSS - #841
3
+ * Update dependencies and testing
4
+
1
5
  4.0.1 (2018-09-02)
2
6
 
3
7
  * Fix incompatibility issue with Slim Include plugin and new ability to specifiy attributes for embedded engines #819
@@ -7,6 +7,12 @@ group :test do
7
7
  gem 'rack-test'
8
8
  end
9
9
 
10
+ group :perf do
11
+ gem 'benchmark-ips'
12
+ gem 'erubis'
13
+ gem 'haml'
14
+ end
15
+
10
16
  if ENV['TRAVIS']
11
17
  gem 'rails-controller-testing'
12
18
  end
@@ -30,19 +36,12 @@ if ENV['RAILS']
30
36
  else
31
37
  gem 'rails', "= #{ENV['RAILS']}"
32
38
  end
33
- end
34
39
 
35
- #Choose minitest 4.7.x for sinatra < 1.4.6 or rails 3 and 4.0 otherwise go for newer version
36
- if (ENV['SINATRA'] && ENV['SINATRA'] < '1.4.6') || (ENV['RAILS'] && ENV['RAILS'].match(/^(3|4\.0)/))
37
- gem 'minitest', '~> 4.7.4'
38
- else
39
- gem 'minitest', '~> 5.1'
40
+ gem 'slim-rails', require: false
40
41
  end
41
42
 
42
- #Ruby >= 2.2.0 has removed test/unit from Stdlib
43
- if RUBY_VERSION >= '2.2.0'
44
- gem 'test-unit', platforms: :mri
45
- end
43
+ gem 'test-unit', '~> 3.3', '>= 3.3.5'
44
+ gem 'minitest', '~> 5.14'
46
45
 
47
46
  if RUBY_ENGINE == 'rbx' && !ENV['TRAVIS']
48
47
  gem 'psych'
@@ -56,9 +55,9 @@ if ENV['SINATRA']
56
55
  end
57
56
  end
58
57
 
59
- gem 'rake', '>= 0.8.7'
60
- gem 'sass', '>= 3.1.0'
61
- gem 'kramdown'
58
+ gem 'rake', '~> 13.0', '>= 13.0.1'
59
+ gem 'sassc', '~> 2.2', '>= 2.2.1'
60
+ gem 'kramdown', '~> 2.1'
62
61
 
63
62
  if ENV['TASK'] == 'bench'
64
63
  gem 'benchmark-ips'
@@ -110,19 +110,19 @@ module Slim
110
110
  Template.new(@options[:file]) { @options[:input].read }.render(nil, locals)
111
111
  end
112
112
 
113
- rescue Exception => ex
114
- raise ex if @options[:trace] || SystemExit === ex
115
- $stderr.print "#{ex.class}: " if ex.class != RuntimeError
116
- $stderr.puts ex.message
117
- $stderr.puts ' Use --trace for backtrace.'
118
- exit 1
119
- else
120
- unless @options[:output]
121
- file = args.shift
122
- @options[:output] = file ? File.open(file, 'w') : $stdout
123
- end
124
- @options[:output].puts(result)
125
- exit 0
113
+ rescue Exception => ex
114
+ raise ex if @options[:trace] || SystemExit === ex
115
+ $stderr.print "#{ex.class}: " if ex.class != RuntimeError
116
+ $stderr.puts ex.message
117
+ $stderr.puts ' Use --trace for backtrace.'
118
+ exit 1
119
+ else
120
+ unless @options[:output]
121
+ file = args.shift
122
+ @options[:output] = file ? File.open(file, 'w') : $stdout
123
+ end
124
+ @options[:output].puts(result)
125
+ exit 0
126
126
  end
127
127
  end
128
128
  end
@@ -70,7 +70,7 @@ module Slim
70
70
  end
71
71
  end
72
72
  keys = Regexp.union @attr_shortcut.keys.sort_by {|k| -k.size }
73
- @attr_shortcut_re = /\A(#{keys}+)((?:\p{Word}|-)*)/
73
+ @attr_shortcut_re = /\A(#{keys}+)((?:\p{Word}|-|\/\d+|:(\w|-)+)*)/
74
74
  keys = Regexp.union @tag_shortcut.keys.sort_by {|k| -k.size }
75
75
  @tag_re = /\A(?:#{keys}|\*(?=[^\s]+)|(\p{Word}(?:\p{Word}|:|-)*\p{Word}|\p{Word}+))/
76
76
  keys = Regexp.escape @code_attr_delims.keys.join
@@ -1,5 +1,5 @@
1
1
  module Slim
2
2
  # Slim version string
3
3
  # @api public
4
- VERSION = '4.0.1'
4
+ VERSION = '4.1.0'
5
5
  end