-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bump rexml from 3.3.4 to 3.3.6 #666
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem compare rexml 3.3.4 3.3.6 Compared versions: ["3.3.4", "3.3.6"]
DIFFERENT date:
3.3.4: 2024-08-01 00:00:00 UTC
3.3.6: 2024-08-22 00:00:00 UTC
DIFFERENT metadata:
3.3.4: {"changelog_uri"=>"https://github.com/ruby/rexml/releases/tag/v3.3.4"}
3.3.6: {"changelog_uri"=>"https://github.com/ruby/rexml/releases/tag/v3.3.6"}
DIFFERENT version:
3.3.4: 3.3.4
3.3.6: 3.3.6
DIFFERENT files:
3.3.4->3.3.6:
* Changed:
NEWS.md +56/-0
lib/rexml/element.rb +14/-16
lib/rexml/entity.rb +5/-47
lib/rexml/parsers/baseparser.rb +103/-35
lib/rexml/parsers/streamparser.rb +7/-9
lib/rexml/parsers/treeparser.rb +0/-7
lib/rexml/rexml.rb +1/-1
DIFFERENT extra_rdoc_files:
3.3.4->3.3.6:
* Changed:
NEWS.md +56/-0 |
gem compare --diff rexml 3.3.4 3.3.6 Compared versions: ["3.3.4", "3.3.6"]
DIFFERENT files:
3.3.4->3.3.6:
* Changed:
NEWS.md
--- /tmp/d20240822-1900-gourkf/rexml-3.3.4/NEWS.md 2024-08-22 21:00:19.589829403 +0000
+++ /tmp/d20240822-1900-gourkf/rexml-3.3.6/NEWS.md 2024-08-22 21:00:19.601829457 +0000
@@ -2,0 +3,56 @@
+## 3.3.6 - 2024-08-22 {#version-3-3-6}
+
+### Improvements
+
+ * Removed duplicated entity expansions for performance.
+ * GH-194
+ * Patch by Viktor Ivarsson.
+
+ * Improved namespace conflicted attribute check performance. It was
+ too slow for deep elements.
+ * Reported by l33thaxor.
+
+### Fixes
+
+ * Fixed a bug that default entity expansions are counted for
+ security check. Default entity expansions should not be counted
+ because they don't have a security risk.
+ * GH-198
+ * GH-199
+ * Patch Viktor Ivarsson
+
+ * Fixed a parser bug that parameter entity references in internal
+ subsets are expanded. It's not allowed in the XML specification.
+ * GH-191
+ * Patch by NAITOH Jun.
+
+ * Fixed a stream parser bug that user-defined entity references in
+ text aren't expanded.
+ * GH-200
+ * Patch by NAITOH Jun.
+
+### Thanks
+
+ * Viktor Ivarsson
+
+ * NAITOH Jun
+
+ * l33thaxor
+
+## 3.3.5 - 2024-08-12 {#version-3-3-5}
+
+### Fixes
+
+ * Fixed a bug that `REXML::Security.entity_expansion_text_limit`
+ check has wrong text size calculation in SAX and pull parsers.
+ * GH-193
+ * GH-195
+ * Reported by Viktor Ivarsson.
+ * Patch by NAITOH Jun.
+
+### Thanks
+
+ * Viktor Ivarsson
+
+ * NAITOH Jun
+
lib/rexml/element.rb
--- /tmp/d20240822-1900-gourkf/rexml-3.3.4/lib/rexml/element.rb 2024-08-22 21:00:19.593829421 +0000
+++ /tmp/d20240822-1900-gourkf/rexml-3.3.6/lib/rexml/element.rb 2024-08-22 21:00:19.605829475 +0000
@@ -444,3 +444,8 @@
- return elements[1] if self.kind_of? Document
- return self if parent.kind_of? Document or parent.nil?
- return parent.root
+ target = self
+ while target
+ return target.elements[1] if target.kind_of? Document
+ parent = target.parent
+ return target if parent.kind_of? Document or parent.nil?
+ target = parent
+ end
+ nil
@@ -622,2 +627,6 @@
- ns = attributes[ prefix ]
- ns = parent.namespace(prefix) if ns.nil? and parent
+ ns = nil
+ target = self
+ while ns.nil? and target
+ ns = target.attributes[prefix]
+ target = target.parent
+ end
@@ -2378,11 +2386,0 @@
- # Check for conflicting namespaces
- if value.prefix != "xmlns" and old_attr.prefix != "xmlns"
- old_namespace = old_attr.namespace
- new_namespace = value.namespace
- if old_namespace == new_namespace
- raise ParseException.new(
- "Namespace conflict in adding attribute \"#{value.name}\": "+
- "Prefix \"#{old_attr.prefix}\" = \"#{old_namespace}\" and "+
- "prefix \"#{value.prefix}\" = \"#{new_namespace}\"")
- end
- end
lib/rexml/entity.rb
--- /tmp/d20240822-1900-gourkf/rexml-3.3.4/lib/rexml/entity.rb 2024-08-22 21:00:19.593829421 +0000
+++ /tmp/d20240822-1900-gourkf/rexml-3.3.6/lib/rexml/entity.rb 2024-08-22 21:00:19.605829475 +0000
@@ -14,0 +15 @@
+ PEREFERENCE_RE = /#{PEREFERENCE}/um
@@ -22 +23 @@
- attr_reader :name, :external, :ref, :ndata, :pubid
+ attr_reader :name, :external, :ref, :ndata, :pubid, :value
@@ -71,2 +72 @@
- # all entities -- both %ent; and &ent; entities. This differs from
- # +value()+ in that +value+ only replaces %ent; entities.
+ # &ent; entities.
@@ -75,4 +75,2 @@
- v = value()
- return nil if v.nil?
- @unnormalized = Text::unnormalize(v, parent)
- @unnormalized
+ return nil if @value.nil?
+ @unnormalized = Text::unnormalize(@value, parent)
@@ -122,40 +119,0 @@
- rv
- end
-
- PEREFERENCE_RE = /#{PEREFERENCE}/um
- # Returns the value of this entity. At the moment, only internal entities
- # are processed. If the value contains internal references (IE,
- # %blah;), those are replaced with their values. IE, if the doctype
- # contains:
- # <!ENTITY % foo "bar">
- # <!ENTITY yada "nanoo %foo; nanoo>
- # then:
- # doctype.entity('yada').value #-> "nanoo bar nanoo"
- def value
- @resolved_value ||= resolve_value
- end
-
- def parent=(other)
- @resolved_value = nil
- super
- end
-
- private
- def resolve_value
- return nil if @value.nil?
- return @value unless @value.match?(PEREFERENCE_RE)
-
- matches = @value.scan(PEREFERENCE_RE)
- rv = @value.clone
- if @parent
- sum = 0
- matches.each do |entity_reference|
- entity_value = @parent.entity( entity_reference[0] )
- if sum + entity_value.bytesize > Security.entity_expansion_text_limit
- raise "entity expansion has grown too large"
- else
- sum += entity_value.bytesize
- end
- rv.gsub!( /%#{entity_reference.join};/um, entity_value )
- end
- end
lib/rexml/parsers/baseparser.rb
--- /tmp/d20240822-1900-gourkf/rexml-3.3.4/lib/rexml/parsers/baseparser.rb 2024-08-22 21:00:19.597829440 +0000
+++ /tmp/d20240822-1900-gourkf/rexml-3.3.6/lib/rexml/parsers/baseparser.rb 2024-08-22 21:00:19.605829475 +0000
@@ -10,0 +11,16 @@
+ unless [].respond_to?(:tally)
+ module EnumerableTally
+ refine Enumerable do
+ def tally
+ counts = {}
+ each do |item|
+ counts[item] ||= 0
+ counts[item] += 1
+ end
+ counts
+ end
+ end
+ end
+ using EnumerableTally
+ end
+
@@ -127,0 +144 @@
+ PEREFERENCE_PATTERN = /#{PEREFERENCE}/um
@@ -167 +184,2 @@
- @nsstack = []
+ @namespaces = {}
+ @namespaces_restore_stack = []
@@ -234,0 +253,4 @@
+ unless @tags.empty?
+ path = "/" + @tags.join("/")
+ raise ParseException.new("Missing end tag for '#{path}'", @source)
+ end
@@ -267 +288,0 @@
- @nsstack.unshift(Set.new)
@@ -336,0 +358,2 @@
+ elsif Private::PEREFERENCE_PATTERN.match?(match[2])
+ raise REXML::ParseException.new("Parameter entity references forbidden in internal subset: #{match[2]}", @source)
@@ -359 +382 @@
- @nsstack[0] << $1
+ @namespaces[$1] = val
@@ -412 +435 @@
- @nsstack.shift
+ @namespaces_restore_stack.pop
@@ -457,2 +480,2 @@
- @nsstack.unshift(curr_ns=Set.new)
- attributes, closed = parse_attributes(@prefixes, curr_ns)
+ push_namespaces_restore
+ attributes, closed = parse_attributes(@prefixes)
@@ -461 +484 @@
- unless @nsstack.find{|k| k.member?(prefix)}
+ unless @namespaces.key?(prefix)
@@ -468 +491 @@
- @nsstack.shift
+ pop_namespaces_restore
@@ -508,9 +531,7 @@
- value = nil
- value = entities[ reference ] if entities
- if value
- record_entity_expansion
- else
- value = DEFAULT_ENTITIES[ reference ]
- value = value[2] if value
- end
- unnormalize( value, entities ) if value
+ return unless entities
+
+ value = entities[ reference ]
+ return if value.nil?
+
+ record_entity_expansion
+ unnormalize( value, entities )
@@ -549,0 +571,5 @@
+ if filter
+ matches.reject! do |entity_reference|
+ filter.include?(entity_reference)
+ end
+ end
@@ -551,14 +577,13 @@
- sum = 0
- matches.each do |entity_reference|
- unless filter and filter.include?(entity_reference)
- entity_value = entity( entity_reference, entities )
- if entity_value
- re = Private::DEFAULT_ENTITIES_PATTERNS[entity_reference] || /&#{entity_reference};/
- rv.gsub!( re, entity_value )
- sum += rv.bytesize
- if sum > Security.entity_expansion_text_limit
- raise "entity expansion has grown too large"
- end
- else
- er = DEFAULT_ENTITIES[entity_reference]
- rv.gsub!( er[0], er[2] ) if er
+ matches.tally.each do |entity_reference, n|
+ entity_expansion_count_before = @entity_expansion_count
+ entity_value = entity( entity_reference, entities )
+ if entity_value
+ if n > 1
+ entity_expansion_count_delta =
+ @entity_expansion_count - entity_expansion_count_before
+ record_entity_expansion(entity_expansion_count_delta * (n - 1))
+ end
+ re = Private::DEFAULT_ENTITIES_PATTERNS[entity_reference] || /&#{entity_reference};/
+ rv.gsub!( re, entity_value )
+ if rv.bytesize > Security.entity_expansion_text_limit
+ raise "entity expansion has grown too large"
@@ -565,0 +591,3 @@
+ else
+ er = DEFAULT_ENTITIES[entity_reference]
+ rv.gsub!( er[0], er[2] ) if er
@@ -573,0 +602,25 @@
+ def add_namespace(prefix, uri)
+ @namespaces_restore_stack.last[prefix] = @namespaces[prefix]
+ if uri.nil?
+ @namespaces.delete(prefix)
+ else
+ @namespaces[prefix] = uri
+ end
+ end
+
+ def push_namespaces_restore
+ namespaces_restore = {}
+ @namespaces_restore_stack.push(namespaces_restore)
+ namespaces_restore
+ end
+
+ def pop_namespaces_restore
+ namespaces_restore = @namespaces_restore_stack.pop
+ namespaces_restore.each do |prefix, uri|
+ if uri.nil?
+ @namespaces.delete(prefix)
+ else
+ @namespaces[prefix] = uri
+ end
+ end
+ end
@@ -575,2 +628,2 @@
- def record_entity_expansion
- @entity_expansion_count += 1
+ def record_entity_expansion(delta=1)
+ @entity_expansion_count += delta
@@ -702 +755 @@
- def parse_attributes(prefixes, curr_ns)
+ def parse_attributes(prefixes)
@@ -703,0 +757 @@
+ expanded_names = {}
@@ -745 +799 @@
- curr_ns << local_part
+ add_namespace(local_part, value)
@@ -752,0 +807,14 @@
+ end
+
+ unless prefix == "xmlns"
+ uri = @namespaces[prefix]
+ expanded_name = [uri, local_part]
+ existing_prefix = expanded_names[expanded_name]
+ if existing_prefix
+ message = "Namespace conflict in adding attribute " +
+ "\"#{local_part}\": " +
+ "Prefix \"#{existing_prefix}\" = \"#{uri}\" and " +
+ "prefix \"#{prefix}\" = \"#{uri}\""
+ raise REXML::ParseException.new(message, @source, self)
+ end
+ expanded_names[expanded_name] = prefix
lib/rexml/parsers/streamparser.rb
--- /tmp/d20240822-1900-gourkf/rexml-3.3.4/lib/rexml/parsers/streamparser.rb 2024-08-22 21:00:19.597829440 +0000
+++ /tmp/d20240822-1900-gourkf/rexml-3.3.6/lib/rexml/parsers/streamparser.rb 2024-08-22 21:00:19.605829475 +0000
@@ -10 +10 @@
- @tag_stack = []
+ @entities = {}
@@ -16,0 +17,4 @@
+ def entity_expansion_count
+ @parser.entity_expansion_count
+ end
+
@@ -23,5 +26,0 @@
- unless @tag_stack.empty?
- tag_path = "/" + @tag_stack.join("/")
- raise ParseException.new("Missing end tag for '#{tag_path}'",
- @parser.source)
- end
@@ -30 +28,0 @@
- @tag_stack << event[1]
@@ -37 +34,0 @@
- @tag_stack.pop
@@ -39 +36 @@
- unnormalized = @parser.unnormalize( event[1] )
+ unnormalized = @parser.unnormalize( event[1], @entities )
@@ -50,0 +48 @@
+ @entities[ event[1] ] = event[2] if event.size == 3
lib/rexml/parsers/treeparser.rb
--- /tmp/d20240822-1900-gourkf/rexml-3.3.4/lib/rexml/parsers/treeparser.rb 2024-08-22 21:00:19.597829440 +0000
+++ /tmp/d20240822-1900-gourkf/rexml-3.3.6/lib/rexml/parsers/treeparser.rb 2024-08-22 21:00:19.605829475 +0000
@@ -18 +17,0 @@
- tag_stack = []
@@ -26,4 +24,0 @@
- unless tag_stack.empty?
- raise ParseException.new("No close tag for #{@build_context.xpath}",
- @parser.source, @parser)
- end
@@ -32 +26,0 @@
- tag_stack.push(event[1])
@@ -38 +31,0 @@
- tag_stack.pop
lib/rexml/rexml.rb
--- /tmp/d20240822-1900-gourkf/rexml-3.3.4/lib/rexml/rexml.rb 2024-08-22 21:00:19.597829440 +0000
+++ /tmp/d20240822-1900-gourkf/rexml-3.3.6/lib/rexml/rexml.rb 2024-08-22 21:00:19.609829493 +0000
@@ -34 +34 @@
- VERSION = "3.3.4"
+ VERSION = "3.3.6" |
dependabot
bot
force-pushed
the
dependabot/bundler/rexml-3.3.6
branch
from
September 9, 2024 05:02
fb53e60
to
6580191
Compare
Bumps [rexml](https://github.com/ruby/rexml) from 3.3.4 to 3.3.6. - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](ruby/rexml@v3.3.4...v3.3.6) --- updated-dependencies: - dependency-name: rexml dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]>
dependabot
bot
force-pushed
the
dependabot/bundler/rexml-3.3.6
branch
from
September 20, 2024 08:20
6580191
to
4c93d58
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bumps rexml from 3.3.4 to 3.3.6.
Release notes
Sourced from rexml's releases.
... (truncated)
Changelog
Sourced from rexml's changelog.
... (truncated)
Commits
95871f3
Add 3.3.6 entry7cb5eae
parser tree: improve namespace conflicted attribute check performance6109e01
Fix a bug that Stream parser doesn't expand the user-defined entity reference...cb15858
parser: keep the current namespaces instead of stack of Set2b47b16
parser: move duplicated end tag check to BaseParser35e1681
test tree-parser: move common method to base class6e00a14
test: fix indentdf3a0cc
test: fix indentfdbffe7
Use loop instead of recursive call for Element#namespace6422fa3
Use loop instead of recursive call for Element#rootDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
@dependabot rebase
will rebase this PR@dependabot recreate
will recreate this PR, overwriting any edits that have been made to it@dependabot merge
will merge this PR after your CI passes on it@dependabot squash and merge
will squash and merge this PR after your CI passes on it@dependabot cancel merge
will cancel a previously requested merge and block automerging@dependabot reopen
will reopen this PR if it is closed@dependabot close
will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually@dependabot show <dependency name> ignore conditions
will show all of the ignore conditions of the specified dependency@dependabot ignore this major version
will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this minor version
will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)@dependabot ignore this dependency
will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)You can disable automated security fix PRs for this repo from the Security Alerts page.