fix: support encode styled string if length larger than offset (#3254)

This commit is contained in:
Connor Tumbleson 2023-08-07 19:52:34 -04:00 committed by GitHub
parent 50226e50c1
commit 22d792e328
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -157,8 +157,11 @@ public class StyledString {
}
// write encoded raw text preceding the closing tag
if (spanEnd > lastOffset) {
if (spanEnd > lastOffset && text.length() >= spanEnd) {
xmlValue.append(ResXmlEncoders.escapeXmlChars(text.substring(lastOffset, spanEnd)));
} else if (text.length() >= lastOffset && text.length() < spanEnd) {
LOGGER.warning("Span (" + name + ") exceeds text length " + text.length());
xmlValue.append(ResXmlEncoders.escapeXmlChars(text.substring(lastOffset)));
}
lastOffset = spanEnd;