mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-06 10:05:54 +01:00
correctly handle incorrect type labeled <array>'s
This commit is contained in:
parent
4b180bd13c
commit
e91790e676
1
CHANGES
1
CHANGES
@ -26,6 +26,7 @@ v2.0.0 (TBA)
|
||||
-Fixed (issue #524) - INSTALL_FAILED_DEXOPT fix (JesusFreke)
|
||||
-Fixed (issue #473) - multiple package frameworks are treated correctly.
|
||||
-Fixed (issue #531) - JAR disassembling borking is fixed
|
||||
-Fixed (issue #550) - Corectly labels incorrect type handling of <array>
|
||||
-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)
|
||||
|
@ -21,6 +21,8 @@ import brut.androlib.res.data.ResResource;
|
||||
import brut.androlib.res.xml.ResValuesXmlSerializable;
|
||||
import brut.util.Duo;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
/**
|
||||
@ -49,9 +51,6 @@ public class ResArrayValue extends ResBagValue implements
|
||||
ResResource res) throws IOException, AndrolibException {
|
||||
String type = getType();
|
||||
type = (type == null ? "" : type + "-") + "array";
|
||||
if ("reference-array".equals(type)) {
|
||||
type = "string-array";
|
||||
}
|
||||
serializer.startTag(null, type);
|
||||
serializer.attribute(null, "name", res.getResSpec().getName());
|
||||
for (int i = 0; i < mItems.length; i++) {
|
||||
@ -71,19 +70,24 @@ public class ResArrayValue extends ResBagValue implements
|
||||
|
||||
if (mItems[i].encodeAsResXmlItemValue().startsWith("@string")) {
|
||||
return "string";
|
||||
} else if (mItems[i].encodeAsResXmlItemValue().startsWith(
|
||||
"@drawable")) {
|
||||
} else if (mItems[i].encodeAsResXmlItemValue().startsWith("@drawable")) {
|
||||
return null;
|
||||
} else if (mItems[i].encodeAsResXmlItemValue().startsWith("@integer")) {
|
||||
return "integer";
|
||||
} else if (!"string".equals(type) && !"integer".equals(type)) {
|
||||
return null;
|
||||
} else if (!type.equals(mItems[i].getType())) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (!Arrays.asList(AllowedArrayTypes).contains(type)) {
|
||||
return "string";
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
private final ResScalarValue[] mItems;
|
||||
private final String AllowedArrayTypes[] = {"string", "integer"};
|
||||
|
||||
public static final int BAG_KEY_ARRAY_START = 0x02000000;
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sun.corba.se.impl.orb.ParserTable;
|
||||
import org.custommonkey.xmlunit.*;
|
||||
import org.junit.*;
|
||||
import static org.junit.Assert.*;
|
||||
@ -76,7 +78,12 @@ public class BuildAndDecodeTest {
|
||||
@Test
|
||||
public void valuesArraysTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc001/arrays.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void valuesArraysCastingTest() throws BrutException {
|
||||
compareValuesFiles("values-mcc002/arrays.xml");
|
||||
compareValuesFiles("values-mcc003/arrays.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="test_array4">
|
||||
<item>3.0in</item>
|
||||
</string-array>
|
||||
<string-array name="test_array5">
|
||||
<item>65.0%</item>
|
||||
<item>65%</item>
|
||||
</string-array>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user