brakeman 4.8.0 → 5.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (273) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +144 -2
  3. data/README.md +23 -6
  4. data/bundle/load.rb +7 -5
  5. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/CHANGELOG.md +24 -0
  6. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/FAQ.md +0 -0
  7. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/Gemfile +1 -4
  8. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/MIT-LICENSE +0 -0
  9. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/README.md +21 -16
  10. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/REFERENCE.md +39 -10
  11. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/TODO +0 -0
  12. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/haml.gemspec +2 -1
  13. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/attribute_builder.rb +58 -3
  14. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/attribute_compiler.rb +45 -32
  15. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/attribute_parser.rb +0 -0
  16. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/buffer.rb +0 -56
  17. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/compiler.rb +0 -0
  18. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/engine.rb +0 -0
  19. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/error.rb +0 -0
  20. data/bundle/ruby/2.7.0/gems/haml-5.2.2/lib/haml/escapable.rb +77 -0
  21. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/exec.rb +0 -0
  22. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/filters.rb +0 -0
  23. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/generator.rb +0 -0
  24. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/helpers/action_view_extensions.rb +0 -0
  25. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/helpers/action_view_mods.rb +0 -0
  26. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/helpers/action_view_xss_mods.rb +0 -0
  27. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/helpers/safe_erubi_template.rb +0 -0
  28. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/helpers/safe_erubis_template.rb +0 -0
  29. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/helpers/xss_mods.rb +6 -3
  30. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/helpers.rb +7 -1
  31. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/options.rb +0 -0
  32. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/parser.rb +32 -4
  33. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/plugin.rb +18 -1
  34. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/railtie.rb +5 -0
  35. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/sass_rails_filter.rb +0 -0
  36. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/template/options.rb +0 -0
  37. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/template.rb +0 -0
  38. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/temple_engine.rb +2 -1
  39. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/temple_line_counter.rb +0 -0
  40. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/util.rb +1 -1
  41. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml/version.rb +1 -1
  42. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/lib/haml.rb +0 -0
  43. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/yard/default/fulldoc/html/css/common.sass +0 -0
  44. data/bundle/ruby/2.7.0/gems/{haml-5.1.2 → haml-5.2.2}/yard/default/layout/html/footer.erb +0 -0
  45. data/bundle/ruby/2.7.0/gems/parallel-1.21.0/MIT-LICENSE.txt +20 -0
  46. data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel/processor_count.rb +45 -0
  47. data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel/version.rb +4 -0
  48. data/bundle/ruby/2.7.0/gems/parallel-1.21.0/lib/parallel.rb +532 -0
  49. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/LICENSE.txt +22 -0
  50. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/NEWS.md +178 -0
  51. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/README.md +48 -0
  52. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/attlistdecl.rb +63 -0
  53. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/attribute.rb +205 -0
  54. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/cdata.rb +68 -0
  55. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/child.rb +97 -0
  56. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/comment.rb +80 -0
  57. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/doctype.rb +311 -0
  58. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/document.rb +451 -0
  59. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/dtd/attlistdecl.rb +11 -0
  60. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/dtd/dtd.rb +47 -0
  61. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/dtd/elementdecl.rb +18 -0
  62. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/dtd/entitydecl.rb +57 -0
  63. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/dtd/notationdecl.rb +40 -0
  64. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/element.rb +2599 -0
  65. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/encoding.rb +51 -0
  66. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/entity.rb +171 -0
  67. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/formatters/default.rb +116 -0
  68. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/formatters/pretty.rb +142 -0
  69. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/formatters/transitive.rb +58 -0
  70. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/functions.rb +447 -0
  71. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/instruction.rb +79 -0
  72. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/light/node.rb +188 -0
  73. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/namespace.rb +59 -0
  74. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/node.rb +76 -0
  75. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/output.rb +30 -0
  76. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parent.rb +166 -0
  77. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parseexception.rb +52 -0
  78. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/baseparser.rb +694 -0
  79. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/lightparser.rb +59 -0
  80. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/pullparser.rb +197 -0
  81. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/sax2parser.rb +273 -0
  82. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/streamparser.rb +61 -0
  83. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/treeparser.rb +101 -0
  84. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/ultralightparser.rb +57 -0
  85. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/parsers/xpathparser.rb +689 -0
  86. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/quickpath.rb +266 -0
  87. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/rexml.rb +37 -0
  88. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/sax2listener.rb +98 -0
  89. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/security.rb +28 -0
  90. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/source.rb +298 -0
  91. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/streamlistener.rb +93 -0
  92. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/text.rb +424 -0
  93. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/undefinednamespaceexception.rb +9 -0
  94. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/validation/relaxng.rb +539 -0
  95. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/validation/validation.rb +144 -0
  96. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/validation/validationexception.rb +10 -0
  97. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/xmldecl.rb +130 -0
  98. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/xmltokens.rb +85 -0
  99. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/xpath.rb +81 -0
  100. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml/xpath_parser.rb +974 -0
  101. data/bundle/ruby/2.7.0/gems/rexml-3.2.5/lib/rexml.rb +3 -0
  102. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/History.rdoc +148 -0
  103. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/Manifest.txt +7 -0
  104. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/README.rdoc +1 -0
  105. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/compare/normalize.rb +51 -6
  106. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/debugging.md +190 -0
  107. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/gauntlet.md +106 -0
  108. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/rp_extensions.rb +15 -36
  109. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/rp_stringscanner.rb +33 -0
  110. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby20_parser.rb +7128 -0
  111. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby20_parser.y +420 -296
  112. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby21_parser.rb +7182 -0
  113. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby21_parser.y +415 -293
  114. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby22_parser.rb +7228 -0
  115. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby22_parser.y +419 -295
  116. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby23_parser.rb +7237 -0
  117. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby23_parser.y +419 -295
  118. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby24_parser.rb +7268 -0
  119. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby24_parser.y +419 -295
  120. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby25_parser.rb +7268 -0
  121. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2/lib/ruby26_parser.y → ruby_parser-3.18.1/lib/ruby25_parser.y} +418 -308
  122. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby26_parser.rb +7287 -0
  123. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2/lib/ruby_parser.yy → ruby_parser-3.18.1/lib/ruby26_parser.y} +419 -399
  124. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby27_parser.rb +8517 -0
  125. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2/lib/ruby25_parser.y → ruby_parser-3.18.1/lib/ruby27_parser.y} +1030 -294
  126. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby30_parser.rb +8751 -0
  127. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby30_parser.y +3472 -0
  128. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby3_parser.yy +3476 -0
  129. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby_lexer.rb +308 -605
  130. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby_lexer.rex +33 -27
  131. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby_lexer.rex.rb +65 -31
  132. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby_lexer_strings.rb +638 -0
  133. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby_parser.rb +4 -0
  134. data/bundle/ruby/2.7.0/gems/ruby_parser-3.18.1/lib/ruby_parser.yy +3487 -0
  135. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/lib/ruby_parser_extras.rb +341 -127
  136. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/tools/munge.rb +43 -10
  137. data/bundle/ruby/2.7.0/gems/{ruby_parser-3.14.2 → ruby_parser-3.18.1}/tools/ripper.rb +15 -10
  138. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/History.rdoc +39 -0
  139. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/Manifest.txt +0 -0
  140. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/README.rdoc +0 -0
  141. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/lib/composite_sexp_processor.rb +0 -0
  142. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/lib/pt_testcase.rb +9 -4
  143. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/lib/sexp.rb +19 -9
  144. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/lib/sexp_matcher.rb +4 -7
  145. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/lib/sexp_processor.rb +1 -1
  146. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/lib/strict_sexp.rb +25 -3
  147. data/bundle/ruby/2.7.0/gems/{sexp_processor-4.14.1 → sexp_processor-4.16.0}/lib/unique.rb +0 -0
  148. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/CHANGES +4 -0
  149. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/Gemfile +12 -13
  150. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/LICENSE +0 -0
  151. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/README.jp.md +0 -0
  152. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/README.md +0 -0
  153. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/code_attributes.rb +0 -0
  154. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/command.rb +13 -13
  155. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/controls.rb +0 -0
  156. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/do_inserter.rb +0 -0
  157. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/embedded.rb +0 -0
  158. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/end_inserter.rb +0 -0
  159. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/engine.rb +0 -0
  160. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/erb_converter.rb +0 -0
  161. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/filter.rb +0 -0
  162. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/grammar.rb +0 -0
  163. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/include.rb +0 -0
  164. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/interpolation.rb +0 -0
  165. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/logic_less/context.rb +0 -0
  166. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/logic_less/filter.rb +0 -0
  167. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/logic_less.rb +0 -0
  168. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/parser.rb +1 -1
  169. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/smart/escaper.rb +0 -0
  170. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/smart/filter.rb +0 -0
  171. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/smart/parser.rb +0 -0
  172. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/smart.rb +0 -0
  173. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/splat/builder.rb +0 -0
  174. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/splat/filter.rb +0 -0
  175. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/template.rb +0 -0
  176. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/translator.rb +0 -0
  177. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim/version.rb +1 -1
  178. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/lib/slim.rb +0 -0
  179. data/bundle/ruby/2.7.0/gems/{slim-4.0.1 → slim-4.1.0}/slim.gemspec +0 -0
  180. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.8.0}/CHANGELOG.md +8 -0
  181. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.8.0}/MIT-LICENSE.txt +0 -0
  182. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.8.0}/README.md +1 -1
  183. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.8.0/data/display_width.marshal.gz +0 -0
  184. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.8.0}/lib/unicode/display_width/constants.rb +2 -2
  185. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.8.0}/lib/unicode/display_width/index.rb +0 -0
  186. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.8.0}/lib/unicode/display_width/no_string_ext.rb +0 -0
  187. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.8.0}/lib/unicode/display_width/string_ext.rb +0 -0
  188. data/bundle/ruby/2.7.0/gems/{unicode-display_width-1.6.1 → unicode-display_width-1.8.0}/lib/unicode/display_width.rb +0 -0
  189. data/lib/brakeman/app_tree.rb +37 -4
  190. data/lib/brakeman/checks/base_check.rb +18 -2
  191. data/lib/brakeman/checks/check_basic_auth.rb +2 -0
  192. data/lib/brakeman/checks/check_csrf_token_forgery_cve.rb +28 -0
  193. data/lib/brakeman/checks/check_deserialize.rb +21 -1
  194. data/lib/brakeman/checks/check_detailed_exceptions.rb +1 -1
  195. data/lib/brakeman/checks/check_eol_rails.rb +23 -0
  196. data/lib/brakeman/checks/check_eol_ruby.rb +26 -0
  197. data/lib/brakeman/checks/check_evaluation.rb +1 -1
  198. data/lib/brakeman/checks/check_execute.rb +12 -1
  199. data/lib/brakeman/checks/check_json_entity_escape.rb +38 -0
  200. data/lib/brakeman/checks/check_json_parsing.rb +1 -1
  201. data/lib/brakeman/checks/check_mass_assignment.rb +37 -9
  202. data/lib/brakeman/checks/check_model_attr_accessible.rb +1 -1
  203. data/lib/brakeman/checks/check_model_attributes.rb +1 -1
  204. data/lib/brakeman/checks/check_page_caching_cve.rb +37 -0
  205. data/lib/brakeman/checks/check_permit_attributes.rb +1 -1
  206. data/lib/brakeman/checks/check_regex_dos.rb +1 -1
  207. data/lib/brakeman/checks/check_render.rb +15 -1
  208. data/lib/brakeman/checks/check_sanitize_methods.rb +2 -1
  209. data/lib/brakeman/checks/check_skip_before_filter.rb +4 -4
  210. data/lib/brakeman/checks/check_sql.rb +60 -9
  211. data/lib/brakeman/checks/check_symbol_dos.rb +1 -1
  212. data/lib/brakeman/checks/check_template_injection.rb +32 -0
  213. data/lib/brakeman/checks/check_unsafe_reflection_methods.rb +68 -0
  214. data/lib/brakeman/checks/check_verb_confusion.rb +75 -0
  215. data/lib/brakeman/checks/eol_check.rb +47 -0
  216. data/lib/brakeman/commandline.rb +25 -1
  217. data/lib/brakeman/file_parser.rb +58 -22
  218. data/lib/brakeman/options.rb +39 -2
  219. data/lib/brakeman/parsers/template_parser.rb +26 -3
  220. data/lib/brakeman/processors/alias_processor.rb +132 -24
  221. data/lib/brakeman/processors/base_processor.rb +4 -4
  222. data/lib/brakeman/processors/controller_alias_processor.rb +6 -43
  223. data/lib/brakeman/processors/controller_processor.rb +1 -1
  224. data/lib/brakeman/processors/gem_processor.rb +3 -0
  225. data/lib/brakeman/processors/haml_template_processor.rb +17 -1
  226. data/lib/brakeman/processors/lib/call_conversion_helper.rb +13 -7
  227. data/lib/brakeman/processors/lib/file_type_detector.rb +64 -0
  228. data/lib/brakeman/processors/lib/find_all_calls.rb +28 -13
  229. data/lib/brakeman/processors/lib/rails3_config_processor.rb +16 -16
  230. data/lib/brakeman/processors/lib/rails3_route_processor.rb +2 -0
  231. data/lib/brakeman/processors/lib/rails4_config_processor.rb +2 -1
  232. data/lib/brakeman/processors/lib/render_helper.rb +3 -1
  233. data/lib/brakeman/processors/library_processor.rb +9 -0
  234. data/lib/brakeman/processors/model_processor.rb +32 -0
  235. data/lib/brakeman/processors/output_processor.rb +1 -1
  236. data/lib/brakeman/processors/template_alias_processor.rb +5 -0
  237. data/lib/brakeman/report/ignore/config.rb +5 -1
  238. data/lib/brakeman/report/ignore/interactive.rb +1 -1
  239. data/lib/brakeman/report/report_base.rb +0 -2
  240. data/lib/brakeman/report/report_csv.rb +37 -60
  241. data/lib/brakeman/report/report_github.rb +31 -0
  242. data/lib/brakeman/report/report_junit.rb +2 -2
  243. data/lib/brakeman/report/report_sarif.rb +133 -0
  244. data/lib/brakeman/report/report_sonar.rb +38 -0
  245. data/lib/brakeman/report/report_tabs.rb +1 -1
  246. data/lib/brakeman/report/report_text.rb +38 -17
  247. data/lib/brakeman/report.rb +19 -1
  248. data/lib/brakeman/rescanner.rb +7 -5
  249. data/lib/brakeman/scanner.rb +65 -31
  250. data/lib/brakeman/tracker/collection.rb +57 -7
  251. data/lib/brakeman/tracker/config.rb +87 -5
  252. data/lib/brakeman/tracker/constants.rb +8 -7
  253. data/lib/brakeman/tracker/controller.rb +1 -1
  254. data/lib/brakeman/tracker/method_info.rb +70 -0
  255. data/lib/brakeman/tracker.rb +42 -5
  256. data/lib/brakeman/util.rb +58 -21
  257. data/lib/brakeman/version.rb +1 -1
  258. data/lib/brakeman/warning.rb +10 -2
  259. data/lib/brakeman/warning_codes.rb +13 -0
  260. data/lib/brakeman.rb +45 -6
  261. data/lib/ruby_parser/bm_sexp.rb +33 -9
  262. metadata +201 -123
  263. data/bundle/ruby/2.7.0/gems/haml-5.1.2/lib/haml/escapable.rb +0 -50
  264. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/debugging.md +0 -18
  265. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/rp_stringscanner.rb +0 -64
  266. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/ruby20_parser.rb +0 -7042
  267. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/ruby21_parser.rb +0 -7113
  268. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/ruby22_parser.rb +0 -7146
  269. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/ruby23_parser.rb +0 -7163
  270. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/ruby24_parser.rb +0 -7175
  271. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/ruby25_parser.rb +0 -7175
  272. data/bundle/ruby/2.7.0/gems/ruby_parser-3.14.2/lib/ruby26_parser.rb +0 -7195
  273. data/bundle/ruby/2.7.0/gems/unicode-display_width-1.6.1/data/display_width.marshal.gz +0 -0
@@ -0,0 +1,447 @@
1
+ # frozen_string_literal: false
2
+ module REXML
3
+ # If you add a method, keep in mind two things:
4
+ # (1) the first argument will always be a list of nodes from which to
5
+ # filter. In the case of context methods (such as position), the function
6
+ # should return an array with a value for each child in the array.
7
+ # (2) all method calls from XML will have "-" replaced with "_".
8
+ # Therefore, in XML, "local-name()" is identical (and actually becomes)
9
+ # "local_name()"
10
+ module Functions
11
+ @@available_functions = {}
12
+ @@context = nil
13
+ @@namespace_context = {}
14
+ @@variables = {}
15
+
16
+ INTERNAL_METHODS = [
17
+ :namespace_context,
18
+ :namespace_context=,
19
+ :variables,
20
+ :variables=,
21
+ :context=,
22
+ :get_namespace,
23
+ :send,
24
+ ]
25
+ class << self
26
+ def singleton_method_added(name)
27
+ unless INTERNAL_METHODS.include?(name)
28
+ @@available_functions[name] = true
29
+ end
30
+ end
31
+ end
32
+
33
+ def Functions::namespace_context=(x) ; @@namespace_context=x ; end
34
+ def Functions::variables=(x) ; @@variables=x ; end
35
+ def Functions::namespace_context ; @@namespace_context ; end
36
+ def Functions::variables ; @@variables ; end
37
+
38
+ def Functions::context=(value); @@context = value; end
39
+
40
+ def Functions::text( )
41
+ if @@context[:node].node_type == :element
42
+ return @@context[:node].find_all{|n| n.node_type == :text}.collect{|n| n.value}
43
+ elsif @@context[:node].node_type == :text
44
+ return @@context[:node].value
45
+ else
46
+ return false
47
+ end
48
+ end
49
+
50
+ # Returns the last node of the given list of nodes.
51
+ def Functions::last( )
52
+ @@context[:size]
53
+ end
54
+
55
+ def Functions::position( )
56
+ @@context[:index]
57
+ end
58
+
59
+ # Returns the size of the given list of nodes.
60
+ def Functions::count( node_set )
61
+ node_set.size
62
+ end
63
+
64
+ # Since REXML is non-validating, this method is not implemented as it
65
+ # requires a DTD
66
+ def Functions::id( object )
67
+ end
68
+
69
+ def Functions::local_name(node_set=nil)
70
+ get_namespace(node_set) do |node|
71
+ return node.local_name
72
+ end
73
+ ""
74
+ end
75
+
76
+ def Functions::namespace_uri( node_set=nil )
77
+ get_namespace( node_set ) {|node| node.namespace}
78
+ end
79
+
80
+ def Functions::name( node_set=nil )
81
+ get_namespace( node_set ) do |node|
82
+ node.expanded_name
83
+ end
84
+ end
85
+
86
+ # Helper method.
87
+ def Functions::get_namespace( node_set = nil )
88
+ if node_set == nil
89
+ yield @@context[:node] if @@context[:node].respond_to?(:namespace)
90
+ else
91
+ if node_set.respond_to? :each
92
+ result = []
93
+ node_set.each do |node|
94
+ result << yield(node) if node.respond_to?(:namespace)
95
+ end
96
+ result
97
+ elsif node_set.respond_to? :namespace
98
+ yield node_set
99
+ end
100
+ end
101
+ end
102
+
103
+ # A node-set is converted to a string by returning the string-value of the
104
+ # node in the node-set that is first in document order. If the node-set is
105
+ # empty, an empty string is returned.
106
+ #
107
+ # A number is converted to a string as follows
108
+ #
109
+ # NaN is converted to the string NaN
110
+ #
111
+ # positive zero is converted to the string 0
112
+ #
113
+ # negative zero is converted to the string 0
114
+ #
115
+ # positive infinity is converted to the string Infinity
116
+ #
117
+ # negative infinity is converted to the string -Infinity
118
+ #
119
+ # if the number is an integer, the number is represented in decimal form
120
+ # as a Number with no decimal point and no leading zeros, preceded by a
121
+ # minus sign (-) if the number is negative
122
+ #
123
+ # otherwise, the number is represented in decimal form as a Number
124
+ # including a decimal point with at least one digit before the decimal
125
+ # point and at least one digit after the decimal point, preceded by a
126
+ # minus sign (-) if the number is negative; there must be no leading zeros
127
+ # before the decimal point apart possibly from the one required digit
128
+ # immediately before the decimal point; beyond the one required digit
129
+ # after the decimal point there must be as many, but only as many, more
130
+ # digits as are needed to uniquely distinguish the number from all other
131
+ # IEEE 754 numeric values.
132
+ #
133
+ # The boolean false value is converted to the string false. The boolean
134
+ # true value is converted to the string true.
135
+ #
136
+ # An object of a type other than the four basic types is converted to a
137
+ # string in a way that is dependent on that type.
138
+ def Functions::string( object=@@context[:node] )
139
+ if object.respond_to?(:node_type)
140
+ case object.node_type
141
+ when :attribute
142
+ object.value
143
+ when :element
144
+ string_value(object)
145
+ when :document
146
+ string_value(object.root)
147
+ when :processing_instruction
148
+ object.content
149
+ else
150
+ object.to_s
151
+ end
152
+ else
153
+ case object
154
+ when Array
155
+ string(object[0])
156
+ when Float
157
+ if object.nan?
158
+ "NaN"
159
+ else
160
+ integer = object.to_i
161
+ if object == integer
162
+ "%d" % integer
163
+ else
164
+ object.to_s
165
+ end
166
+ end
167
+ else
168
+ object.to_s
169
+ end
170
+ end
171
+ end
172
+
173
+ # A node-set is converted to a string by
174
+ # returning the concatenation of the string-value
175
+ # of each of the children of the node in the
176
+ # node-set that is first in document order.
177
+ # If the node-set is empty, an empty string is returned.
178
+ def Functions::string_value( o )
179
+ rv = ""
180
+ o.children.each { |e|
181
+ if e.node_type == :text
182
+ rv << e.to_s
183
+ elsif e.node_type == :element
184
+ rv << string_value( e )
185
+ end
186
+ }
187
+ rv
188
+ end
189
+
190
+ def Functions::concat( *objects )
191
+ concatenated = ""
192
+ objects.each do |object|
193
+ concatenated << string(object)
194
+ end
195
+ concatenated
196
+ end
197
+
198
+ # Fixed by Mike Stok
199
+ def Functions::starts_with( string, test )
200
+ string(string).index(string(test)) == 0
201
+ end
202
+
203
+ # Fixed by Mike Stok
204
+ def Functions::contains( string, test )
205
+ string(string).include?(string(test))
206
+ end
207
+
208
+ # Kouhei fixed this
209
+ def Functions::substring_before( string, test )
210
+ ruby_string = string(string)
211
+ ruby_index = ruby_string.index(string(test))
212
+ if ruby_index.nil?
213
+ ""
214
+ else
215
+ ruby_string[ 0...ruby_index ]
216
+ end
217
+ end
218
+
219
+ # Kouhei fixed this too
220
+ def Functions::substring_after( string, test )
221
+ ruby_string = string(string)
222
+ return $1 if ruby_string =~ /#{test}(.*)/
223
+ ""
224
+ end
225
+
226
+ # Take equal portions of Mike Stok and Sean Russell; mix
227
+ # vigorously, and pour into a tall, chilled glass. Serves 10,000.
228
+ def Functions::substring( string, start, length=nil )
229
+ ruby_string = string(string)
230
+ ruby_length = if length.nil?
231
+ ruby_string.length.to_f
232
+ else
233
+ number(length)
234
+ end
235
+ ruby_start = number(start)
236
+
237
+ # Handle the special cases
238
+ return '' if (
239
+ ruby_length.nan? or
240
+ ruby_start.nan? or
241
+ ruby_start.infinite?
242
+ )
243
+
244
+ infinite_length = ruby_length.infinite? == 1
245
+ ruby_length = ruby_string.length if infinite_length
246
+
247
+ # Now, get the bounds. The XPath bounds are 1..length; the ruby bounds
248
+ # are 0..length. Therefore, we have to offset the bounds by one.
249
+ ruby_start = round(ruby_start) - 1
250
+ ruby_length = round(ruby_length)
251
+
252
+ if ruby_start < 0
253
+ ruby_length += ruby_start unless infinite_length
254
+ ruby_start = 0
255
+ end
256
+ return '' if ruby_length <= 0
257
+ ruby_string[ruby_start,ruby_length]
258
+ end
259
+
260
+ # UNTESTED
261
+ def Functions::string_length( string )
262
+ string(string).length
263
+ end
264
+
265
+ # UNTESTED
266
+ def Functions::normalize_space( string=nil )
267
+ string = string(@@context[:node]) if string.nil?
268
+ if string.kind_of? Array
269
+ string.collect{|x| string.to_s.strip.gsub(/\s+/um, ' ') if string}
270
+ else
271
+ string.to_s.strip.gsub(/\s+/um, ' ')
272
+ end
273
+ end
274
+
275
+ # This is entirely Mike Stok's beast
276
+ def Functions::translate( string, tr1, tr2 )
277
+ from = string(tr1)
278
+ to = string(tr2)
279
+
280
+ # the map is our translation table.
281
+ #
282
+ # if a character occurs more than once in the
283
+ # from string then we ignore the second &
284
+ # subsequent mappings
285
+ #
286
+ # if a character maps to nil then we delete it
287
+ # in the output. This happens if the from
288
+ # string is longer than the to string
289
+ #
290
+ # there's nothing about - or ^ being special in
291
+ # http://www.w3.org/TR/xpath#function-translate
292
+ # so we don't build ranges or negated classes
293
+
294
+ map = Hash.new
295
+ 0.upto(from.length - 1) { |pos|
296
+ from_char = from[pos]
297
+ unless map.has_key? from_char
298
+ map[from_char] =
299
+ if pos < to.length
300
+ to[pos]
301
+ else
302
+ nil
303
+ end
304
+ end
305
+ }
306
+
307
+ if ''.respond_to? :chars
308
+ string(string).chars.collect { |c|
309
+ if map.has_key? c then map[c] else c end
310
+ }.compact.join
311
+ else
312
+ string(string).unpack('U*').collect { |c|
313
+ if map.has_key? c then map[c] else c end
314
+ }.compact.pack('U*')
315
+ end
316
+ end
317
+
318
+ def Functions::boolean(object=@@context[:node])
319
+ case object
320
+ when true, false
321
+ object
322
+ when Float
323
+ return false if object.zero?
324
+ return false if object.nan?
325
+ true
326
+ when Numeric
327
+ not object.zero?
328
+ when String
329
+ not object.empty?
330
+ when Array
331
+ not object.empty?
332
+ else
333
+ object ? true : false
334
+ end
335
+ end
336
+
337
+ # UNTESTED
338
+ def Functions::not( object )
339
+ not boolean( object )
340
+ end
341
+
342
+ # UNTESTED
343
+ def Functions::true( )
344
+ true
345
+ end
346
+
347
+ # UNTESTED
348
+ def Functions::false( )
349
+ false
350
+ end
351
+
352
+ # UNTESTED
353
+ def Functions::lang( language )
354
+ lang = false
355
+ node = @@context[:node]
356
+ attr = nil
357
+ until node.nil?
358
+ if node.node_type == :element
359
+ attr = node.attributes["xml:lang"]
360
+ unless attr.nil?
361
+ lang = compare_language(string(language), attr)
362
+ break
363
+ else
364
+ end
365
+ end
366
+ node = node.parent
367
+ end
368
+ lang
369
+ end
370
+
371
+ def Functions::compare_language lang1, lang2
372
+ lang2.downcase.index(lang1.downcase) == 0
373
+ end
374
+
375
+ # a string that consists of optional whitespace followed by an optional
376
+ # minus sign followed by a Number followed by whitespace is converted to
377
+ # the IEEE 754 number that is nearest (according to the IEEE 754
378
+ # round-to-nearest rule) to the mathematical value represented by the
379
+ # string; any other string is converted to NaN
380
+ #
381
+ # boolean true is converted to 1; boolean false is converted to 0
382
+ #
383
+ # a node-set is first converted to a string as if by a call to the string
384
+ # function and then converted in the same way as a string argument
385
+ #
386
+ # an object of a type other than the four basic types is converted to a
387
+ # number in a way that is dependent on that type
388
+ def Functions::number(object=@@context[:node])
389
+ case object
390
+ when true
391
+ Float(1)
392
+ when false
393
+ Float(0)
394
+ when Array
395
+ number(string(object))
396
+ when Numeric
397
+ object.to_f
398
+ else
399
+ str = string(object)
400
+ case str.strip
401
+ when /\A\s*(-?(?:\d+(?:\.\d*)?|\.\d+))\s*\z/
402
+ $1.to_f
403
+ else
404
+ Float::NAN
405
+ end
406
+ end
407
+ end
408
+
409
+ def Functions::sum( nodes )
410
+ nodes = [nodes] unless nodes.kind_of? Array
411
+ nodes.inject(0) { |r,n| r + number(string(n)) }
412
+ end
413
+
414
+ def Functions::floor( number )
415
+ number(number).floor
416
+ end
417
+
418
+ def Functions::ceiling( number )
419
+ number(number).ceil
420
+ end
421
+
422
+ def Functions::round( number )
423
+ number = number(number)
424
+ begin
425
+ neg = number.negative?
426
+ number = number.abs.round
427
+ neg ? -number : number
428
+ rescue FloatDomainError
429
+ number
430
+ end
431
+ end
432
+
433
+ def Functions::processing_instruction( node )
434
+ node.node_type == :processing_instruction
435
+ end
436
+
437
+ def Functions::send(name, *args)
438
+ if @@available_functions[name.to_sym]
439
+ super
440
+ else
441
+ # TODO: Maybe, this is not XPath spec behavior.
442
+ # This behavior must be reconsidered.
443
+ XPath.match(@@context[:node], name.to_s)
444
+ end
445
+ end
446
+ end
447
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: false
2
+
3
+ require_relative "child"
4
+ require_relative "source"
5
+
6
+ module REXML
7
+ # Represents an XML Instruction; IE, <? ... ?>
8
+ # TODO: Add parent arg (3rd arg) to constructor
9
+ class Instruction < Child
10
+ START = "<?"
11
+ STOP = "?>"
12
+
13
+ # target is the "name" of the Instruction; IE, the "tag" in <?tag ...?>
14
+ # content is everything else.
15
+ attr_accessor :target, :content
16
+
17
+ # Constructs a new Instruction
18
+ # @param target can be one of a number of things. If String, then
19
+ # the target of this instruction is set to this. If an Instruction,
20
+ # then the Instruction is shallowly cloned (target and content are
21
+ # copied).
22
+ # @param content Must be either a String, or a Parent. Can only
23
+ # be a Parent if the target argument is a Source. Otherwise, this
24
+ # String is set as the content of this instruction.
25
+ def initialize(target, content=nil)
26
+ case target
27
+ when String
28
+ super()
29
+ @target = target
30
+ @content = content
31
+ when Instruction
32
+ super(content)
33
+ @target = target.target
34
+ @content = target.content
35
+ else
36
+ message =
37
+ "processing instruction target must be String or REXML::Instruction: "
38
+ message << "<#{target.inspect}>"
39
+ raise ArgumentError, message
40
+ end
41
+ @content.strip! if @content
42
+ end
43
+
44
+ def clone
45
+ Instruction.new self
46
+ end
47
+
48
+ # == DEPRECATED
49
+ # See the rexml/formatters package
50
+ #
51
+ def write writer, indent=-1, transitive=false, ie_hack=false
52
+ Kernel.warn( "#{self.class.name}.write is deprecated", uplevel: 1)
53
+ indent(writer, indent)
54
+ writer << START
55
+ writer << @target
56
+ if @content
57
+ writer << ' '
58
+ writer << @content
59
+ end
60
+ writer << STOP
61
+ end
62
+
63
+ # @return true if other is an Instruction, and the content and target
64
+ # of the other matches the target and content of this object.
65
+ def ==( other )
66
+ other.kind_of? Instruction and
67
+ other.target == @target and
68
+ other.content == @content
69
+ end
70
+
71
+ def node_type
72
+ :processing_instruction
73
+ end
74
+
75
+ def inspect
76
+ "<?p-i #{target} ...?>"
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,188 @@
1
+ # frozen_string_literal: false
2
+ require_relative '../xmltokens'
3
+
4
+ module REXML
5
+ module Light
6
+ # Represents a tagged XML element. Elements are characterized by
7
+ # having children, attributes, and names, and can themselves be
8
+ # children.
9
+ class Node
10
+ NAMESPLIT = /^(?:(#{XMLTokens::NCNAME_STR}):)?(#{XMLTokens::NCNAME_STR})/u
11
+ PARENTS = [ :element, :document, :doctype ]
12
+ # Create a new element.
13
+ def initialize node=nil
14
+ @node = node
15
+ if node.kind_of? String
16
+ node = [ :text, node ]
17
+ elsif node.nil?
18
+ node = [ :document, nil, nil ]
19
+ elsif node[0] == :start_element
20
+ node[0] = :element
21
+ elsif node[0] == :start_doctype
22
+ node[0] = :doctype
23
+ elsif node[0] == :start_document
24
+ node[0] = :document
25
+ end
26
+ end
27
+
28
+ def size
29
+ if PARENTS.include? @node[0]
30
+ @node[-1].size
31
+ else
32
+ 0
33
+ end
34
+ end
35
+
36
+ def each
37
+ size.times { |x| yield( at(x+4) ) }
38
+ end
39
+
40
+ def name
41
+ at(2)
42
+ end
43
+
44
+ def name=( name_str, ns=nil )
45
+ pfx = ''
46
+ pfx = "#{prefix(ns)}:" if ns
47
+ _old_put(2, "#{pfx}#{name_str}")
48
+ end
49
+
50
+ def parent=( node )
51
+ _old_put(1,node)
52
+ end
53
+
54
+ def local_name
55
+ namesplit
56
+ @name
57
+ end
58
+
59
+ def local_name=( name_str )
60
+ _old_put( 1, "#@prefix:#{name_str}" )
61
+ end
62
+
63
+ def prefix( namespace=nil )
64
+ prefix_of( self, namespace )
65
+ end
66
+
67
+ def namespace( prefix=prefix() )
68
+ namespace_of( self, prefix )
69
+ end
70
+
71
+ def namespace=( namespace )
72
+ @prefix = prefix( namespace )
73
+ pfx = ''
74
+ pfx = "#@prefix:" if @prefix.size > 0
75
+ _old_put(1, "#{pfx}#@name")
76
+ end
77
+
78
+ def []( reference, ns=nil )
79
+ if reference.kind_of? String
80
+ pfx = ''
81
+ pfx = "#{prefix(ns)}:" if ns
82
+ at(3)["#{pfx}#{reference}"]
83
+ elsif reference.kind_of? Range
84
+ _old_get( Range.new(4+reference.begin, reference.end, reference.exclude_end?) )
85
+ else
86
+ _old_get( 4+reference )
87
+ end
88
+ end
89
+
90
+ def =~( path )
91
+ XPath.match( self, path )
92
+ end
93
+
94
+ # Doesn't handle namespaces yet
95
+ def []=( reference, ns, value=nil )
96
+ if reference.kind_of? String
97
+ value = ns unless value
98
+ at( 3 )[reference] = value
99
+ elsif reference.kind_of? Range
100
+ _old_put( Range.new(3+reference.begin, reference.end, reference.exclude_end?), ns )
101
+ else
102
+ if value
103
+ _old_put( 4+reference, ns, value )
104
+ else
105
+ _old_put( 4+reference, ns )
106
+ end
107
+ end
108
+ end
109
+
110
+ # Append a child to this element, optionally under a provided namespace.
111
+ # The namespace argument is ignored if the element argument is an Element
112
+ # object. Otherwise, the element argument is a string, the namespace (if
113
+ # provided) is the namespace the element is created in.
114
+ def << element
115
+ if node_type() == :text
116
+ at(-1) << element
117
+ else
118
+ newnode = Node.new( element )
119
+ newnode.parent = self
120
+ self.push( newnode )
121
+ end
122
+ at(-1)
123
+ end
124
+
125
+ def node_type
126
+ _old_get(0)
127
+ end
128
+
129
+ def text=( foo )
130
+ replace = at(4).kind_of?(String)? 1 : 0
131
+ self._old_put(4,replace, normalizefoo)
132
+ end
133
+
134
+ def root
135
+ context = self
136
+ context = context.at(1) while context.at(1)
137
+ end
138
+
139
+ def has_name?( name, namespace = '' )
140
+ at(3) == name and namespace() == namespace
141
+ end
142
+
143
+ def children
144
+ self
145
+ end
146
+
147
+ def parent
148
+ at(1)
149
+ end
150
+
151
+ def to_s
152
+
153
+ end
154
+
155
+ private
156
+
157
+ def namesplit
158
+ return if @name.defined?
159
+ at(2) =~ NAMESPLIT
160
+ @prefix = '' || $1
161
+ @name = $2
162
+ end
163
+
164
+ def namespace_of( node, prefix=nil )
165
+ if not prefix
166
+ name = at(2)
167
+ name =~ NAMESPLIT
168
+ prefix = $1
169
+ end
170
+ to_find = 'xmlns'
171
+ to_find = "xmlns:#{prefix}" if not prefix.nil?
172
+ ns = at(3)[ to_find ]
173
+ ns ? ns : namespace_of( @node[0], prefix )
174
+ end
175
+
176
+ def prefix_of( node, namespace=nil )
177
+ if not namespace
178
+ name = node.name
179
+ name =~ NAMESPLIT
180
+ $1
181
+ else
182
+ ns = at(3).find { |k,v| v == namespace }
183
+ ns ? ns : prefix_of( node.parent, namespace )
184
+ end
185
+ end
186
+ end
187
+ end
188
+ end