pdvrieze / xmlutil

XML Serialization library for Kotlin
https://pdvrieze.github.io/xmlutil/
Apache License 2.0
377 stars 30 forks source link

XmlUtil.xmlCollapseWhitespace() throws StringIndexOutOfBoundsException on empty attribute #180

Closed armay closed 1 year ago

armay commented 1 year ago

Hi @pdvrieze, I faced a small bug in the latest version (0.86.2; 0.86.1 is not affected). The following line ends up with a StringIndexOutOfBoundsException if original: String is empty:

https://github.com/pdvrieze/xmlutil/blob/d375df5bf1ee31f4a009946fca321b6e733c0184/core/src/commonMain/kotlin/nl/adaptivity/xmlutil/XmlUtil.kt#L49

pdvrieze commented 1 year ago

Just fixed it. Thanks for the report. This is indeed new code, taken from my work on xml schema support (that requires support for collapsing whitespace). In terms of serialization it is used for/needed for supporting attribute lists and attribute maps.

armay commented 1 year ago

Thanks a lot for the quick fix!