diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/StyledString.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/StyledString.java index 057d1d2ee6..fc9affeba0 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/StyledString.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/StyledString.java @@ -157,8 +157,11 @@ private void decodeIterate(PeekingIterator it) { } // 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;