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 d6f03c8a..c1488ebe 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 @@ -131,6 +131,11 @@ public class StringBlock { if (style == null) { return ResXmlEncoders.escapeXmlChars(raw); } + + // If the returned style is further in string, than string length. Lets skip it. + if (style[1] > raw.length()) { + return ResXmlEncoders.escapeXmlChars(raw); + } StringBuilder html = new StringBuilder(raw.length() + 32); int[] opened = new int[style.length / 3]; int offset = 0, depth = 0; diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java index da251858..4a0b252b 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java @@ -253,6 +253,11 @@ public class BuildAndDecodeTest { compareValuesFiles("values-ast/strings.xml"); } + @Test + public void androidOStringTest() throws BrutException, IOException { + compareValuesFiles("values-ast/strings.xml"); + } + @Test public void twoLetterNotHandledAsBcpTest() throws BrutException, IOException { checkFolderExists("res/values-fr"); diff --git a/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-ar-rXB/strings.xml b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-ar-rXB/strings.xml new file mode 100644 index 00000000..687db601 --- /dev/null +++ b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-ar-rXB/strings.xml @@ -0,0 +1,9 @@ + + + "‏‮Forgot‬‏ ‏‮your‬‏ ‏‮username‬‏ ‏‮or‬‏ ‏‮password?‬‏\n‏‮Visit‬‏ ‏‮google.com/accounts/recover‬‏‏‮y‬‏‏‮.‬‏" + ‏‮Forgot‬‏ ‏‮your‬‏ ‏‮username‬‏ ‏‮or‬‏ ‏‮password?‬\n.‏‮Visit‬‏ ‏‮google.com/accounts/recover‬‏‏‮y‬‏ + (string8) "‏‮Forgot‬‏ ‏‮your‬‏ ‏‮username‬‏ ‏‮or‬‏ ‏‮password?‬‏\n‏‮Visit‬‏ ‏‮google.com/accounts/recover‬‏‏‮y‬‏‏‮.‬‏" + Forgot your username or password?\nVisit google.com/accounts/recovery. + ‏‮Forgot‬‏ ‏‮your‬‏ ‏‮username‬‏ ‏‮or‬‏ ‏‮password?‬‏ + ‏‮Visit‬‏ ‏‮google.com/accounts/recover‬‏‏‮y‬‏‏‮.‬‏ + \ No newline at end of file