1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Fix can't modify frozen String error in XmlMini_JDOM

Without this, `XmlMini_JDOM` raises an error as follwing:

```
RuntimeError: can't modify frozen String
    org/jruby/RubyString.java:2264:in `concat'
    activesupport/lib/active_support/xml_mini/jdom.rb:177:in `block in empty_content?'
    org/jruby/RubyRange.java:485:in `each'
    activesupport/lib/active_support/xml_mini/jdom.rb:174:in `empty_content?'
    activesupport/lib/active_support/xml_mini/jdom.rb:86:in `collapse'
    activesupport/lib/active_support/xml_mini/jdom.rb:66:in `merge_element!'
    activesupport/lib/active_support/xml_mini/jdom.rb:84:in `block in collapse'
    org/jruby/RubyRange.java:485:in `each'
    activesupport/lib/active_support/xml_mini/jdom.rb:82:in `collapse'
    activesupport/lib/active_support/xml_mini/jdom.rb:66:in `merge_element!'
    activesupport/lib/active_support/xml_mini/jdom.rb:51:in `parse'
    activesupport/lib/active_support/xml_mini.rb:101:in `parse'
```

We already have tests about `XmlMini_JDOM`. But it is not running in CI.
https://github.com/rails/rails/blob/master/activesupport/test/xml_mini/jdom_engine_test.rb
This commit is contained in:
yuuji.yaginuma 2017-09-01 07:06:59 +09:00
parent aa1dc38dc2
commit e92cd730ea

View file

@ -169,7 +169,7 @@ module ActiveSupport
# element::
# XML element to be checked.
def empty_content?(element)
text = ""
text = "".dup
child_nodes = element.child_nodes
(0...child_nodes.length).each do |i|
item = child_nodes.item(i)