Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#441 StringIndexOutOfBounds in XMLIndenter

v8.6.1
closed
Michael Kay
5
2012-10-08
2005-12-10
Michael Kay
No

A StringIndexOutOfBounds exception may occur in the
XMLIndenter module when the indentation depth is
unusually high. With the typical indentation depth of
three spaces, the problem occurs when elements are
nested 27-deep, and the stack trace then starts like this:

java.lang.StringIndexOutOfBoundsException: String index
out of range: 82
at java.lang.String.substring(Unknown Source)
at java.lang.String.subSequence(Unknown Source)
at
net.sf.saxon.event.XMLIndenter.indent(XMLIndenter.java:182)

The problem is present in Saxon 8.6.1 and all known
previous releases.

Source fix: at line 177 of
net.sf.saxon.event.XMLIndenter, change

    while (spaces >= indentChars.length()) {
        indentChars += "                      ";
    }

to

    while (spaces+1 >= indentChars.length()) {
        indentChars += "                      ";
    }

Michael Kay

Discussion