diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/ResConfigFlags.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/ResConfigFlags.java index a05204cb..de7e89bc 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/ResConfigFlags.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/ResConfigFlags.java @@ -74,8 +74,8 @@ public class ResConfigFlags { smallestScreenWidthDp = 0; screenWidthDp = 0; screenHeightDp = 0; - localeScript = new char[] { '\00', '\00', '\00', '\00' }; - localeVariant = new char[] { '\00', '\00', '\00', '\00', '\00', '\00', '\00', '\00' }; + localeScript = null; + localeVariant = null; isInvalid = false; mQualifiers = ""; } @@ -114,7 +114,7 @@ public class ResConfigFlags { isInvalid = true; } - if (localeScript.length != 0) { + if (localeScript != null && localeScript.length != 0) { if (localeScript[0] == '\00') { localeScript = null; } @@ -122,7 +122,7 @@ public class ResConfigFlags { localeScript = null; } - if (localeVariant.length != 0) { + if (localeVariant != null && localeVariant.length != 0) { if (localeVariant[0] == '\00') { localeVariant = null; } diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java index d1af5654..78512e2c 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/ARSCDecoder.java @@ -292,11 +292,11 @@ public class ARSCDecoder { screenHeightDp = mIn.readShort(); } - char[] localeScript = {'\00'}; - char[] localeVariant = {'\00'}; + char[] localeScript = null; + char[] localeVariant = null; if (size >= 48) { - localeScript = this.readScriptOrVariantChar(4).toCharArray(); - localeVariant = this.readScriptOrVariantChar(8).toCharArray(); + localeScript = readScriptOrVariantChar(4).toCharArray(); + localeVariant = readScriptOrVariantChar(8).toCharArray(); } int exceedingSize = size - KNOWN_CONFIG_BYTES; 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 cdfc9d27..5b037f8e 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 @@ -207,6 +207,11 @@ public class BuildAndDecodeTest { compareValuesFiles("values-ast/strings.xml"); } + @Test + public void twoLetterNotHandledAsBcpTest() throws BrutException, IOException { + checkFolderExists("res/values-fr"); + } + @Test public void twoLetterLangBcp47Test() throws BrutException, IOException { compareValuesFiles("values-en-rUS/strings.xml"); @@ -361,6 +366,12 @@ public class BuildAndDecodeTest { compareXmlFiles(path, null); } + private void checkFolderExists(String path) throws BrutException { + File f = new File(sTestNewDir, path); + + assertTrue(f.isDirectory()); + } + private void compareXmlFiles(String path, ElementQualifier qualifier) throws BrutException { DetailedDiff diff;