From: Ed Gamble Date: 2009-06-23T09:10:12+09:00 Subject: [ruby-core:23974] REXML pretty.rb --Apple-Mail-24--1026847063 Content-Type: text/plain; charset="US-ASCII"; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit [Sorry if this is the wrong forum; please forward to the proper person/ group. Sorry if this is fixed in a newer version.] In .../lib/ruby/1.8/rexml/formatters/pretty.rb there is an error when writing a long text element that has no spaces. The wrap function in pretty.rb of # Recursively wrap string at width. return string if string.length <= width place = string.rindex(' ', width) # Position in string with last ' ' before cutoff return string[0,place] + "\n" + wrap(string[place+1..-1], width) fails since 'place' can be nil if rindex doesn't find ' '. Subsequently place+1 will fail. Fix/workaround is: if place then return string[0,place] + "\n" + wrap(string[place+1..-1], width) else return string # don't wrap strings with no spaces end Also in .../formatters/default.rb the text in a super long element will simply be truncated - even to the point of leaving off a closing tag. For example: aSUPERlongTESTelementWITHmaybeHUNDREDSofCHARACTERSlikeTHATproducedFROMcodeGENERATORSofREGULARexpressions (but much longer) gets chopped off such that is lost and the document becomes invalid. -- Ed Ed Gamble Jet Propulsion Laboratory, MS 301-270 4800 Oak Grove Drive Pasadena, CA 91109 Desk: 818-393-6357 Cell: 805-403-9864 Room: 301-280T Exploring the Universe, one spacecraft at a time. Google Engineering culture: "Nothing speaks louder than code," NY Times, 16 Dec 2007 --Apple-Mail-24--1026847063 Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable [Sorry if this is the wrong = forum; please forward to the proper person/group.  Sorry if this is = fixed in a newer version.]

In = .../lib/ruby/1.8/rexml/formatters/pretty.rb there is an error when = writing a long text element that has no spaces.  The wrap function = in pretty.rb of

       =  # Recursively wrap string at width.
     =    return string if string.length <=3D = width
        place =3D = string.rindex(' ', width) # Position in string with last ' ' before = cutoff
        return string[0,place] = + "\n" + wrap(string[place+1..-1], width)

fails = since 'place' can be nil if rindex doesn't find ' '.  Subsequently = place+1 will fail.

Fix/workaround = is:

if place then
  = return string[0,place] + "\n" + wrap(string[place+1..-1], = width)
= else
           = return string  # don't wrap strings with no spaces
= end

Also in .../formatters/default.rb = the text in a super long element will simply be truncated - even to the = point of leaving off a closing tag.  For example:
= <some-element>aSUPERlongTESTelementWITHmaybeHUNDREDSofCHARACT= ERSlikeTHATproducedFROMcodeGENERATORSofREGULARexpressions</some-element= >

(but much longer) gets chopped off such = that </some-element> is lost and the document becomes = invalid.

-- = Ed

=
Jet Propulsion Laboratory, MS = 301-270
4800 Oak Grove Drive

=   = 818-393-6357
Cell:  = 805-403-9864
Room:  = 301-280T


Google Engineering culture: = "Nothing speaks louder than code," NY Times, 16 Dec 2007



= --Apple-Mail-24--1026847063--