stax-utils
  1. stax-utils
  2. STAX_UTILS-15

getTextCharacters source start param wrong

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: www
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      15

      Description

      I have found a problem in the class XMLStreamReaderToContentHandler class.

      The method handleCharacters() (line 229) calls javax.xml.stream.XMLStreamReader
      with the incorrect sourceStart parameter (first parameter).

      The method currently calls:
      staxStreamReader.getTextCharacters(textStart, chars, 0, textLength);

      textStart is obtained from a call to staxStreamReader.getTextStart(). From the
      Javadoc description for the method "Returns the offset into the text character
      array where the first character (of this text event) is stored.". This method
      can not be used as the first argument to the getTextCharacters(....) method
      "sourceStart - the index of the first character in the source array to copy".
      i.e. the code is trying to set the starting point for the copy as the position
      in the character array for the XML chunk rather than the character array for the
      text even.t

      The fix is to change the line to:
      staxStreamReader.getTextCharacters(0, chars, 0, textLength);

        Activity

        Hide
        rockclimb added a comment -

        Looking at the JRE source, this doesn't appear to be valid. The way it's being used, getTextStart() will return zero anyway.

        Show
        rockclimb added a comment - Looking at the JRE source, this doesn't appear to be valid. The way it's being used, getTextStart() will return zero anyway.
        Hide
        priyarr added a comment -

        Hi rockclimb, I am also seeing the same issue that tsmith has pointed out. With the current code, am getting an Array Index Out of bounds exception since the sourcestart was greater in the same methods as specified in this bug. And as suggested, if i change the first parameter to "0", everything works fine as expected. I am running a parser program in java 1.4 and needed this stax-utils api.

        When I run my parser program in java 1.6 everything was fine. But with 1.4, nonetheless, the stax-utils API helped a ton and this fix pointed here was awesome)))thanks a bunch both of you!

        Show
        priyarr added a comment - Hi rockclimb, I am also seeing the same issue that tsmith has pointed out. With the current code, am getting an Array Index Out of bounds exception since the sourcestart was greater in the same methods as specified in this bug. And as suggested, if i change the first parameter to "0", everything works fine as expected. I am running a parser program in java 1.4 and needed this stax-utils api. When I run my parser program in java 1.6 everything was fine. But with 1.4, nonetheless, the stax-utils API helped a ton and this fix pointed here was awesome )))thanks a bunch both of you!

          People

          • Assignee:
            stax-utils-issues
            Reporter:
            tsmith
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: