#441 StringIndexOutOfBounds in XMLIndenter

v8.6.1
closed
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

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks