Skip to content

StringIndexOutOfBoundsException in XMLWriter.writeElementContent() #26

@marianpetras

Description

@marianpetras

If the following conditions are met:

  • text-padding format is used – see OutputFormat.setPadText(boolean)
  • the XML document contains a node containing a mixture of text-nodes and other nodes
  • at least one of the mentioned text-nodes is empty

... then method XMLWriter.writeElementContent(Element) may throw a StringIndexOutOfBoundsException.

The cause is that the code assumes that the text of a text-node is never empty. But if the text is empty, then an attempt to get the first character fails with the exception.

A suggested patch is attached.

patch.zip

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions