M src/rexml/formatters/pretty.rb +3 -1
@@ 128,7 128,9 @@ module REXML
def wrap(string, width)
# Recursivly wrap string at width.
return string if string.length <= width
- place = string.rindex(' ', width) # Position in string with last ' ' before cutoff
+ place = string.rindex(/\s/, width) # Position in string with last ' ' before cutoff
+ place = string.index(/\s/) if place.nil? # Otherwise first space
+ return string if place.nil? # otherwise, whole string
return string[0,place] + "\n" + wrap(string[place+1..-1], width)
end
M test/core_test.rb +12 -0
@@ 1349,6 1349,18 @@ ENDXML
doc.root.elements["item[@name='foo']"].to_s
end
+ def test_ticket_135
+ bean_element = REXML::Element.new("bean")
+ textToAdd = "(&(|(memberof=CN=somegroupabcdefgh,OU=OUsucks,DC=hookemhorns,DC=com)(mail=*someco.com))(acct=%u)(!(extraparameter:2.2.222.222222.2.2.222:=2)))"
+ bean_element.add_element("prop", {"key"=> "filter"}).add_text(textToAdd)
+ doc = REXML::Document.new
+ doc.add_element(bean_element)
+
+ REXML::Formatters::Pretty.new(3).write( doc, out = "" )
+
+ assert_equal "<bean>\n <prop key='filter'>\n (&#38;(|(memberof=CN=somegroupabcdefgh,OU=OUsucks,DC=hookemhorns,DC=com)(mail=*someco.com))(acct=%u)(!(extraparameter:2.2.222.222222.2.2.222:=2)))\n </prop>\n</bean>", out
+ end
+
def test_ticket_138
doc = REXML::Document.new(
'<svg xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" ' +