diff --git a/CHANGES b/CHANGES index ea7a8885..efea3077 100644 --- a/CHANGES +++ b/CHANGES @@ -33,6 +33,7 @@ v2.0.0 (TBA) -Fixed (issue #601) - Make StringBlock thread safe (Thanks aluedeke) -Fixed (issue #238) - Fixed truncated UTF-16 strings -Fixed (issue #584) - Fixed horrible spacing, aligned for 4 spaces. +-Fixed (issue #196) - Fixed style crash due to malformed styles. -Added output to list Apktool version to help debugging. -Updated known bytes for configurations to 38 (from addition of layout direction) -Fixed NPE when handling odex apks even with --no-src specified. (Thanks Rodrigo Chiossi) diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/StringBlock.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/StringBlock.java index ebe18d72..38686d16 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/StringBlock.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/StringBlock.java @@ -184,18 +184,27 @@ public class StringBlock { boolean loop = true; while (loop) { int pos2 = tag.indexOf('=', pos + 1); - builder.append(' ').append(tag.substring(pos + 1, pos2)).append("=\""); - pos = tag.indexOf(';', pos2 + 1); - String val; - if (pos != -1) { - val = tag.substring(pos2 + 1, pos); + // malformed style information will cause crash. so + // prematurely end style tags, if recreation + // cannot be created. + if (pos2 != -1) { + builder.append(' ').append(tag.substring(pos + 1, pos2)).append("=\""); + pos = tag.indexOf(';', pos2 + 1); + + String val; + if (pos != -1) { + val = tag.substring(pos2 + 1, pos); + } else { + loop = false; + val = tag.substring(pos2 + 1); + } + + builder.append(ResXmlEncoders.escapeXmlChars(val)).append('"'); } else { loop = false; - val = tag.substring(pos2 + 1); } - builder.append(ResXmlEncoders.escapeXmlChars(val)).append('"'); } } } diff --git a/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-fr/strings.xml b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-fr/strings.xml new file mode 100644 index 00000000..ad496d77 --- /dev/null +++ b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-fr/strings.xml @@ -0,0 +1,5 @@ + + + http://www.foo.com + http://www.foo.com + \ No newline at end of file