brakeman 4.10.1 → 5.0.0.pre1

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 +9 -7
  3. data/README.md +1 -1
  4. data/bundle/load.rb +8 -9
  5. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/CHANGELOG.md +1 -8
  6. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/FAQ.md +0 -0
  7. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/Gemfile +0 -0
  8. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/MIT-LICENSE +0 -0
  9. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/README.md +0 -0
  10. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/REFERENCE.md +5 -9
  11. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/TODO +0 -0
  12. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/haml.gemspec +1 -1
  13. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml.rb +0 -0
  14. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/attribute_builder.rb +0 -0
  15. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/attribute_compiler.rb +0 -0
  16. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/attribute_parser.rb +0 -0
  17. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/buffer.rb +0 -0
  18. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/compiler.rb +0 -0
  19. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/engine.rb +0 -0
  20. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/error.rb +0 -0
  21. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/escapable.rb +0 -0
  22. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/exec.rb +0 -0
  23. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/filters.rb +0 -0
  24. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/generator.rb +0 -0
  25. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/helpers.rb +0 -0
  26. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/helpers/action_view_extensions.rb +0 -0
  27. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/helpers/action_view_mods.rb +0 -0
  28. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/helpers/action_view_xss_mods.rb +0 -0
  29. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/helpers/safe_erubi_template.rb +0 -0
  30. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/helpers/safe_erubis_template.rb +0 -0
  31. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/helpers/xss_mods.rb +0 -0
  32. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/options.rb +0 -0
  33. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/parser.rb +3 -31
  34. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/plugin.rb +0 -0
  35. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/railtie.rb +0 -0
  36. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/sass_rails_filter.rb +0 -0
  37. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/template.rb +0 -0
  38. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/template/options.rb +0 -0
  39. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/temple_engine.rb +0 -0
  40. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/temple_line_counter.rb +0 -0
  41. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/util.rb +1 -1
  42. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/lib/haml/version.rb +1 -1
  43. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/yard/default/fulldoc/html/css/common.sass +0 -0
  44. data/bundle/ruby/2.7.0/gems/{haml-5.2.1 → haml-5.2.0}/yard/default/layout/html/footer.erb +0 -0
  45. data/lib/brakeman.rb +6 -0
  46. data/lib/brakeman/app_tree.rb +36 -3
  47. data/lib/brakeman/checks/check_execute.rb +1 -1
  48. data/lib/brakeman/checks/check_regex_dos.rb +1 -1
  49. data/lib/brakeman/checks/check_unsafe_reflection_methods.rb +68 -0
  50. data/lib/brakeman/checks/check_verb_confusion.rb +75 -0
  51. data/lib/brakeman/file_parser.rb +19 -23
  52. data/lib/brakeman/options.rb +5 -1
  53. data/lib/brakeman/parsers/template_parser.rb +2 -3
  54. data/lib/brakeman/processors/alias_processor.rb +2 -2
  55. data/lib/brakeman/processors/controller_processor.rb +1 -1
  56. data/lib/brakeman/processors/lib/file_type_detector.rb +64 -0
  57. data/lib/brakeman/processors/output_processor.rb +1 -1
  58. data/lib/brakeman/processors/template_alias_processor.rb +0 -5
  59. data/lib/brakeman/report.rb +8 -0
  60. data/lib/brakeman/report/report_sonar.rb +38 -0
  61. data/lib/brakeman/rescanner.rb +7 -5
  62. data/lib/brakeman/scanner.rb +42 -18
  63. data/lib/brakeman/tracker.rb +6 -0
  64. data/lib/brakeman/tracker/controller.rb +1 -1
  65. data/lib/brakeman/util.rb +9 -4
  66. data/lib/brakeman/version.rb +1 -1
  67. data/lib/brakeman/warning_codes.rb +2 -0
  68. data/lib/ruby_parser/bm_sexp.rb +9 -9
  69. metadata +49 -99
  70. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/Gemfile +0 -6
  71. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/LICENSE.txt +0 -22
  72. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/NEWS.md +0 -141
  73. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/README.md +0 -60
  74. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/attlistdecl.rb +0 -63
  75. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/attribute.rb +0 -205
  76. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/cdata.rb +0 -68
  77. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/child.rb +0 -97
  78. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/comment.rb +0 -80
  79. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/doctype.rb +0 -287
  80. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/document.rb +0 -291
  81. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/dtd/attlistdecl.rb +0 -11
  82. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/dtd/dtd.rb +0 -47
  83. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/dtd/elementdecl.rb +0 -18
  84. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/dtd/entitydecl.rb +0 -57
  85. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/dtd/notationdecl.rb +0 -40
  86. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/element.rb +0 -1269
  87. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/encoding.rb +0 -51
  88. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/entity.rb +0 -171
  89. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/formatters/default.rb +0 -116
  90. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/formatters/pretty.rb +0 -142
  91. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/formatters/transitive.rb +0 -58
  92. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/functions.rb +0 -447
  93. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/instruction.rb +0 -79
  94. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/light/node.rb +0 -196
  95. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/namespace.rb +0 -59
  96. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/node.rb +0 -76
  97. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/output.rb +0 -30
  98. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/parent.rb +0 -166
  99. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/parseexception.rb +0 -52
  100. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/parsers/baseparser.rb +0 -594
  101. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/parsers/lightparser.rb +0 -59
  102. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/parsers/pullparser.rb +0 -197
  103. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/parsers/sax2parser.rb +0 -273
  104. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/parsers/streamparser.rb +0 -61
  105. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/parsers/treeparser.rb +0 -101
  106. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/parsers/ultralightparser.rb +0 -57
  107. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/parsers/xpathparser.rb +0 -675
  108. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/quickpath.rb +0 -266
  109. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/rexml.rb +0 -32
  110. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/sax2listener.rb +0 -98
  111. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/security.rb +0 -28
  112. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/source.rb +0 -298
  113. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/streamlistener.rb +0 -93
  114. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/text.rb +0 -424
  115. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/undefinednamespaceexception.rb +0 -9
  116. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/validation/relaxng.rb +0 -539
  117. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/validation/validation.rb +0 -144
  118. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/validation/validationexception.rb +0 -10
  119. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/xmldecl.rb +0 -130
  120. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/xmltokens.rb +0 -85
  121. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/xpath.rb +0 -81
  122. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/lib/rexml/xpath_parser.rb +0 -968
  123. data/bundle/ruby/2.7.0/gems/rexml-3.2.4/rexml.gemspec +0 -84
@@ -1,60 +0,0 @@
1
- # REXML
2
-
3
- REXML was inspired by the Electric XML library for Java, which features an easy-to-use API, small size, and speed. Hopefully, REXML, designed with the same philosophy, has these same features. I've tried to keep the API as intuitive as possible, and have followed the Ruby methodology for method naming and code flow, rather than mirroring the Java API.
4
-
5
- REXML supports both tree and stream document parsing. Stream parsing is faster (about 1.5 times as fast). However, with stream parsing, you don't get access to features such as XPath.
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'rexml'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install rexml
22
-
23
- ## Usage
24
-
25
- We'll start with parsing an XML document
26
-
27
- ```ruby
28
- require "rexml/document"
29
- file = File.new( "mydoc.xml" )
30
- doc = REXML::Document.new file
31
- ```
32
-
33
- Line 3 creates a new document and parses the supplied file. You can also do the following
34
-
35
- ```ruby
36
- require "rexml/document"
37
- include REXML # so that we don't have to prefix everything with REXML::...
38
- string = <<EOF
39
- <mydoc>
40
- <someelement attribute="nanoo">Text, text, text</someelement>
41
- </mydoc>
42
- EOF
43
- doc = Document.new string
44
- ```
45
-
46
- So parsing a string is just as easy as parsing a file.
47
-
48
- ## Development
49
-
50
- After checking out the repo, run `rake test` to run the tests.
51
-
52
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
53
-
54
- ## Contributing
55
-
56
- Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/rexml.
57
-
58
- ## License
59
-
60
- The gem is available as open source under the terms of the [BSD-2-Clause](LICENSE.txt).
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: false
2
- #vim:ts=2 sw=2 noexpandtab:
3
- require_relative 'child'
4
- require_relative 'source'
5
-
6
- module REXML
7
- # This class needs:
8
- # * Documentation
9
- # * Work! Not all types of attlists are intelligently parsed, so we just
10
- # spew back out what we get in. This works, but it would be better if
11
- # we formatted the output ourselves.
12
- #
13
- # AttlistDecls provide *just* enough support to allow namespace
14
- # declarations. If you need some sort of generalized support, or have an
15
- # interesting idea about how to map the hideous, terrible design of DTD
16
- # AttlistDecls onto an intuitive Ruby interface, let me know. I'm desperate
17
- # for anything to make DTDs more palateable.
18
- class AttlistDecl < Child
19
- include Enumerable
20
-
21
- # What is this? Got me.
22
- attr_reader :element_name
23
-
24
- # Create an AttlistDecl, pulling the information from a Source. Notice
25
- # that this isn't very convenient; to create an AttlistDecl, you basically
26
- # have to format it yourself, and then have the initializer parse it.
27
- # Sorry, but for the foreseeable future, DTD support in REXML is pretty
28
- # weak on convenience. Have I mentioned how much I hate DTDs?
29
- def initialize(source)
30
- super()
31
- if (source.kind_of? Array)
32
- @element_name, @pairs, @contents = *source
33
- end
34
- end
35
-
36
- # Access the attlist attribute/value pairs.
37
- # value = attlist_decl[ attribute_name ]
38
- def [](key)
39
- @pairs[key]
40
- end
41
-
42
- # Whether an attlist declaration includes the given attribute definition
43
- # if attlist_decl.include? "xmlns:foobar"
44
- def include?(key)
45
- @pairs.keys.include? key
46
- end
47
-
48
- # Iterate over the key/value pairs:
49
- # attlist_decl.each { |attribute_name, attribute_value| ... }
50
- def each(&block)
51
- @pairs.each(&block)
52
- end
53
-
54
- # Write out exactly what we got in.
55
- def write out, indent=-1
56
- out << @contents
57
- end
58
-
59
- def node_type
60
- :attlistdecl
61
- end
62
- end
63
- end
@@ -1,205 +0,0 @@
1
- # frozen_string_literal: false
2
- require_relative "namespace"
3
- require_relative 'text'
4
-
5
- module REXML
6
- # Defines an Element Attribute; IE, a attribute=value pair, as in:
7
- # <element attribute="value"/>. Attributes can be in their own
8
- # namespaces. General users of REXML will not interact with the
9
- # Attribute class much.
10
- class Attribute
11
- include Node
12
- include Namespace
13
-
14
- # The element to which this attribute belongs
15
- attr_reader :element
16
- # The normalized value of this attribute. That is, the attribute with
17
- # entities intact.
18
- attr_writer :normalized
19
- PATTERN = /\s*(#{NAME_STR})\s*=\s*(["'])(.*?)\2/um
20
-
21
- NEEDS_A_SECOND_CHECK = /(<|&((#{Entity::NAME});|(#0*((?:\d+)|(?:x[a-fA-F0-9]+)));)?)/um
22
-
23
- # Constructor.
24
- # FIXME: The parser doesn't catch illegal characters in attributes
25
- #
26
- # first::
27
- # Either: an Attribute, which this new attribute will become a
28
- # clone of; or a String, which is the name of this attribute
29
- # second::
30
- # If +first+ is an Attribute, then this may be an Element, or nil.
31
- # If nil, then the Element parent of this attribute is the parent
32
- # of the +first+ Attribute. If the first argument is a String,
33
- # then this must also be a String, and is the content of the attribute.
34
- # If this is the content, it must be fully normalized (contain no
35
- # illegal characters).
36
- # parent::
37
- # Ignored unless +first+ is a String; otherwise, may be the Element
38
- # parent of this attribute, or nil.
39
- #
40
- #
41
- # Attribute.new( attribute_to_clone )
42
- # Attribute.new( attribute_to_clone, parent_element )
43
- # Attribute.new( "attr", "attr_value" )
44
- # Attribute.new( "attr", "attr_value", parent_element )
45
- def initialize( first, second=nil, parent=nil )
46
- @normalized = @unnormalized = @element = nil
47
- if first.kind_of? Attribute
48
- self.name = first.expanded_name
49
- @unnormalized = first.value
50
- if second.kind_of? Element
51
- @element = second
52
- else
53
- @element = first.element
54
- end
55
- elsif first.kind_of? String
56
- @element = parent
57
- self.name = first
58
- @normalized = second.to_s
59
- else
60
- raise "illegal argument #{first.class.name} to Attribute constructor"
61
- end
62
- end
63
-
64
- # Returns the namespace of the attribute.
65
- #
66
- # e = Element.new( "elns:myelement" )
67
- # e.add_attribute( "nsa:a", "aval" )
68
- # e.add_attribute( "b", "bval" )
69
- # e.attributes.get_attribute( "a" ).prefix # -> "nsa"
70
- # e.attributes.get_attribute( "b" ).prefix # -> ""
71
- # a = Attribute.new( "x", "y" )
72
- # a.prefix # -> ""
73
- def prefix
74
- super
75
- end
76
-
77
- # Returns the namespace URL, if defined, or nil otherwise
78
- #
79
- # e = Element.new("el")
80
- # e.add_namespace("ns", "http://url")
81
- # e.add_attribute("ns:a", "b")
82
- # e.add_attribute("nsx:a", "c")
83
- # e.attribute("ns:a").namespace # => "http://url"
84
- # e.attribute("nsx:a").namespace # => nil
85
- #
86
- # This method always returns "" for no namespace attribute. Because
87
- # the default namespace doesn't apply to attribute names.
88
- #
89
- # From https://www.w3.org/TR/xml-names/#uniqAttrs
90
- #
91
- # > the default namespace does not apply to attribute names
92
- #
93
- # e = REXML::Element.new("el")
94
- # e.add_namespace("", "http://example.com/")
95
- # e.namespace # => "http://example.com/"
96
- # e.add_attribute("a", "b")
97
- # e.attribute("a").namespace # => ""
98
- def namespace arg=nil
99
- arg = prefix if arg.nil?
100
- if arg == ""
101
- ""
102
- else
103
- @element.namespace(arg)
104
- end
105
- end
106
-
107
- # Returns true if other is an Attribute and has the same name and value,
108
- # false otherwise.
109
- def ==( other )
110
- other.kind_of?(Attribute) and other.name==name and other.value==value
111
- end
112
-
113
- # Creates (and returns) a hash from both the name and value
114
- def hash
115
- name.hash + value.hash
116
- end
117
-
118
- # Returns this attribute out as XML source, expanding the name
119
- #
120
- # a = Attribute.new( "x", "y" )
121
- # a.to_string # -> "x='y'"
122
- # b = Attribute.new( "ns:x", "y" )
123
- # b.to_string # -> "ns:x='y'"
124
- def to_string
125
- if @element and @element.context and @element.context[:attribute_quote] == :quote
126
- %Q^#@expanded_name="#{to_s().gsub(/"/, '&quot;')}"^
127
- else
128
- "#@expanded_name='#{to_s().gsub(/'/, '&apos;')}'"
129
- end
130
- end
131
-
132
- def doctype
133
- if @element
134
- doc = @element.document
135
- doc.doctype if doc
136
- end
137
- end
138
-
139
- # Returns the attribute value, with entities replaced
140
- def to_s
141
- return @normalized if @normalized
142
-
143
- @normalized = Text::normalize( @unnormalized, doctype )
144
- @unnormalized = nil
145
- @normalized
146
- end
147
-
148
- # Returns the UNNORMALIZED value of this attribute. That is, entities
149
- # have been expanded to their values
150
- def value
151
- return @unnormalized if @unnormalized
152
- @unnormalized = Text::unnormalize( @normalized, doctype )
153
- @normalized = nil
154
- @unnormalized
155
- end
156
-
157
- # Returns a copy of this attribute
158
- def clone
159
- Attribute.new self
160
- end
161
-
162
- # Sets the element of which this object is an attribute. Normally, this
163
- # is not directly called.
164
- #
165
- # Returns this attribute
166
- def element=( element )
167
- @element = element
168
-
169
- if @normalized
170
- Text.check( @normalized, NEEDS_A_SECOND_CHECK, doctype )
171
- end
172
-
173
- self
174
- end
175
-
176
- # Removes this Attribute from the tree, and returns true if successful
177
- #
178
- # This method is usually not called directly.
179
- def remove
180
- @element.attributes.delete self.name unless @element.nil?
181
- end
182
-
183
- # Writes this attribute (EG, puts 'key="value"' to the output)
184
- def write( output, indent=-1 )
185
- output << to_string
186
- end
187
-
188
- def node_type
189
- :attribute
190
- end
191
-
192
- def inspect
193
- rv = ""
194
- write( rv )
195
- rv
196
- end
197
-
198
- def xpath
199
- path = @element.xpath
200
- path += "/@#{self.expanded_name}"
201
- return path
202
- end
203
- end
204
- end
205
- #vim:ts=2 sw=2 noexpandtab:
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: false
2
- require_relative "text"
3
-
4
- module REXML
5
- class CData < Text
6
- START = '<![CDATA['
7
- STOP = ']]>'
8
- ILLEGAL = /(\]\]>)/
9
-
10
- # Constructor. CData is data between <![CDATA[ ... ]]>
11
- #
12
- # _Examples_
13
- # CData.new( source )
14
- # CData.new( "Here is some CDATA" )
15
- # CData.new( "Some unprocessed data", respect_whitespace_TF, parent_element )
16
- def initialize( first, whitespace=true, parent=nil )
17
- super( first, whitespace, parent, false, true, ILLEGAL )
18
- end
19
-
20
- # Make a copy of this object
21
- #
22
- # _Examples_
23
- # c = CData.new( "Some text" )
24
- # d = c.clone
25
- # d.to_s # -> "Some text"
26
- def clone
27
- CData.new self
28
- end
29
-
30
- # Returns the content of this CData object
31
- #
32
- # _Examples_
33
- # c = CData.new( "Some text" )
34
- # c.to_s # -> "Some text"
35
- def to_s
36
- @string
37
- end
38
-
39
- def value
40
- @string
41
- end
42
-
43
- # == DEPRECATED
44
- # See the rexml/formatters package
45
- #
46
- # Generates XML output of this object
47
- #
48
- # output::
49
- # Where to write the string. Defaults to $stdout
50
- # indent::
51
- # The amount to indent this node by
52
- # transitive::
53
- # Ignored
54
- # ie_hack::
55
- # Ignored
56
- #
57
- # _Examples_
58
- # c = CData.new( " Some text " )
59
- # c.write( $stdout ) #-> <![CDATA[ Some text ]]>
60
- def write( output=$stdout, indent=-1, transitive=false, ie_hack=false )
61
- Kernel.warn( "#{self.class.name}.write is deprecated", uplevel: 1)
62
- indent( output, indent )
63
- output << START
64
- output << @string
65
- output << STOP
66
- end
67
- end
68
- end
@@ -1,97 +0,0 @@
1
- # frozen_string_literal: false
2
- require_relative "node"
3
-
4
- module REXML
5
- ##
6
- # A Child object is something contained by a parent, and this class
7
- # contains methods to support that. Most user code will not use this
8
- # class directly.
9
- class Child
10
- include Node
11
- attr_reader :parent # The Parent of this object
12
-
13
- # Constructor. Any inheritors of this class should call super to make
14
- # sure this method is called.
15
- # parent::
16
- # if supplied, the parent of this child will be set to the
17
- # supplied value, and self will be added to the parent
18
- def initialize( parent = nil )
19
- @parent = nil
20
- # Declare @parent, but don't define it. The next line sets the
21
- # parent.
22
- parent.add( self ) if parent
23
- end
24
-
25
- # Replaces this object with another object. Basically, calls
26
- # Parent.replace_child
27
- #
28
- # Returns:: self
29
- def replace_with( child )
30
- @parent.replace_child( self, child )
31
- self
32
- end
33
-
34
- # Removes this child from the parent.
35
- #
36
- # Returns:: self
37
- def remove
38
- unless @parent.nil?
39
- @parent.delete self
40
- end
41
- self
42
- end
43
-
44
- # Sets the parent of this child to the supplied argument.
45
- #
46
- # other::
47
- # Must be a Parent object. If this object is the same object as the
48
- # existing parent of this child, no action is taken. Otherwise, this
49
- # child is removed from the current parent (if one exists), and is added
50
- # to the new parent.
51
- # Returns:: The parent added
52
- def parent=( other )
53
- return @parent if @parent == other
54
- @parent.delete self if defined? @parent and @parent
55
- @parent = other
56
- end
57
-
58
- alias :next_sibling :next_sibling_node
59
- alias :previous_sibling :previous_sibling_node
60
-
61
- # Sets the next sibling of this child. This can be used to insert a child
62
- # after some other child.
63
- # a = Element.new("a")
64
- # b = a.add_element("b")
65
- # c = Element.new("c")
66
- # b.next_sibling = c
67
- # # => <a><b/><c/></a>
68
- def next_sibling=( other )
69
- parent.insert_after self, other
70
- end
71
-
72
- # Sets the previous sibling of this child. This can be used to insert a
73
- # child before some other child.
74
- # a = Element.new("a")
75
- # b = a.add_element("b")
76
- # c = Element.new("c")
77
- # b.previous_sibling = c
78
- # # => <a><b/><c/></a>
79
- def previous_sibling=(other)
80
- parent.insert_before self, other
81
- end
82
-
83
- # Returns:: the document this child belongs to, or nil if this child
84
- # belongs to no document
85
- def document
86
- return parent.document unless parent.nil?
87
- nil
88
- end
89
-
90
- # This doesn't yet handle encodings
91
- def bytes
92
- document.encoding
93
-
94
- to_s
95
- end
96
- end
97
- end