mirror of
https://github.com/revanced/Apktool.git
synced 2024-11-11 15:09:24 +01:00
Prevent casting strings that resemble filepaths to ResFileValues
- add testcase - adapt changes - introduce decodeManifestWithResources which uses attr decoding w/ resources
This commit is contained in:
parent
5d73e25555
commit
4882396163
1
CHANGES
1
CHANGES
@ -52,6 +52,7 @@ v2.0.0 (TBA)
|
|||||||
-Fixed (issue #706) - Added support for TYPE_DYNAMIC_REFERENCE.
|
-Fixed (issue #706) - Added support for TYPE_DYNAMIC_REFERENCE.
|
||||||
-Fixed (issue #685) - Fixed invalid attrs values with Android Lollipop.
|
-Fixed (issue #685) - Fixed invalid attrs values with Android Lollipop.
|
||||||
-Fixed (issue #713) - Fixed issue with packages that had shared library resources.
|
-Fixed (issue #713) - Fixed issue with packages that had shared library resources.
|
||||||
|
-Fixed (issue #329) - Fixed issue with incorrectly identifying similarly named strings as ResFileValues.
|
||||||
-Fixed issue with APKs with multiple dex files.
|
-Fixed issue with APKs with multiple dex files.
|
||||||
-Fixed issue with using Apktool without smali/baksmali for ApktoolProperties (Thanks teprrr)
|
-Fixed issue with using Apktool without smali/baksmali for ApktoolProperties (Thanks teprrr)
|
||||||
-Fixed issue with non-URI standard characters in apk name (Thanks rover12421)
|
-Fixed issue with non-URI standard characters in apk name (Thanks rover12421)
|
||||||
|
@ -131,6 +131,11 @@ public class Androlib {
|
|||||||
mAndRes.decode(resTable, apkFile, outDir);
|
mAndRes.decode(resTable, apkFile, outDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void decodeManifestWithResources(ExtFile apkFile, File outDir, ResTable resTable)
|
||||||
|
throws AndrolibException {
|
||||||
|
mAndRes.decodeManifestWithResources(resTable, apkFile, outDir);
|
||||||
|
}
|
||||||
|
|
||||||
public void decodeRawFiles(ExtFile apkFile, File outDir)
|
public void decodeRawFiles(ExtFile apkFile, File outDir)
|
||||||
throws AndrolibException {
|
throws AndrolibException {
|
||||||
LOGGER.info("Copying assets and libs...");
|
LOGGER.info("Copying assets and libs...");
|
||||||
|
@ -26,6 +26,7 @@ import brut.common.BrutException;
|
|||||||
import brut.directory.DirectoryException;
|
import brut.directory.DirectoryException;
|
||||||
import brut.directory.ZipExtFile;
|
import brut.directory.ZipExtFile;
|
||||||
import brut.util.OS;
|
import brut.util.OS;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -98,6 +99,9 @@ public class ApkDecoder {
|
|||||||
mAndrolib.decodeResourcesRaw(mApkFile, outDir);
|
mAndrolib.decodeResourcesRaw(mApkFile, outDir);
|
||||||
break;
|
break;
|
||||||
case DECODE_RESOURCES_FULL:
|
case DECODE_RESOURCES_FULL:
|
||||||
|
if (hasManifest()) {
|
||||||
|
mAndrolib.decodeManifestWithResources(mApkFile, outDir, getResTable());
|
||||||
|
}
|
||||||
mAndrolib.decodeResourcesFull(mApkFile, outDir, getResTable());
|
mAndrolib.decodeResourcesFull(mApkFile, outDir, getResTable());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -360,6 +364,10 @@ public class ApkDecoder {
|
|||||||
|
|
||||||
HashMap<String, String> packages = new HashMap<String, String>();
|
HashMap<String, String> packages = new HashMap<String, String>();
|
||||||
|
|
||||||
|
if (Strings.isNullOrEmpty(original)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// only put rename-manifest-package into apktool.yml, if the change will be required
|
// only put rename-manifest-package into apktool.yml, if the change will be required
|
||||||
if (!renamed.equalsIgnoreCase(original)) {
|
if (!renamed.equalsIgnoreCase(original)) {
|
||||||
packages.put("rename-manifest-package", renamed);
|
packages.put("rename-manifest-package", renamed);
|
||||||
|
@ -278,8 +278,9 @@ final public class AndrolibResources {
|
|||||||
transformer.transform(source, result);
|
transformer.transform(source, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decode(ResTable resTable, ExtFile apkFile, File outDir)
|
public void decodeManifestWithResources(ResTable resTable, ExtFile apkFile, File outDir)
|
||||||
throws AndrolibException {
|
throws AndrolibException {
|
||||||
|
|
||||||
Duo<ResFileDecoder, AXmlResourceParser> duo = getResFileDecoder();
|
Duo<ResFileDecoder, AXmlResourceParser> duo = getResFileDecoder();
|
||||||
ResFileDecoder fileDecoder = duo.m1;
|
ResFileDecoder fileDecoder = duo.m1;
|
||||||
ResAttrDecoder attrDecoder = duo.m2.getAttrDecoder();
|
ResAttrDecoder attrDecoder = duo.m2.getAttrDecoder();
|
||||||
@ -290,7 +291,6 @@ final public class AndrolibResources {
|
|||||||
try {
|
try {
|
||||||
inApk = apkFile.getDirectory();
|
inApk = apkFile.getDirectory();
|
||||||
out = new FileDirectory(outDir);
|
out = new FileDirectory(outDir);
|
||||||
|
|
||||||
LOGGER.info("Decoding AndroidManifest.xml with resources...");
|
LOGGER.info("Decoding AndroidManifest.xml with resources...");
|
||||||
|
|
||||||
fileDecoder.decodeManifest(inApk, "AndroidManifest.xml", out, "AndroidManifest.xml");
|
fileDecoder.decodeManifest(inApk, "AndroidManifest.xml", out, "AndroidManifest.xml");
|
||||||
@ -306,6 +306,24 @@ final public class AndrolibResources {
|
|||||||
remove_manifest_versions(outDir.getAbsolutePath() + File.separator + "AndroidManifest.xml");
|
remove_manifest_versions(outDir.getAbsolutePath() + File.separator + "AndroidManifest.xml");
|
||||||
mPackageId = String.valueOf(resTable.getPackageId());
|
mPackageId = String.valueOf(resTable.getPackageId());
|
||||||
}
|
}
|
||||||
|
} catch (DirectoryException ex) {
|
||||||
|
throw new AndrolibException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void decode(ResTable resTable, ExtFile apkFile, File outDir)
|
||||||
|
throws AndrolibException {
|
||||||
|
Duo<ResFileDecoder, AXmlResourceParser> duo = getResFileDecoder();
|
||||||
|
ResFileDecoder fileDecoder = duo.m1;
|
||||||
|
ResAttrDecoder attrDecoder = duo.m2.getAttrDecoder();
|
||||||
|
|
||||||
|
attrDecoder.setCurrentPackage(resTable.listMainPackages().iterator().next());
|
||||||
|
Directory inApk, in = null, out;
|
||||||
|
|
||||||
|
try {
|
||||||
|
out = new FileDirectory(outDir);
|
||||||
|
|
||||||
|
inApk = apkFile.getDirectory();
|
||||||
if (inApk.containsDir("res")) {
|
if (inApk.containsDir("res")) {
|
||||||
in = inApk.getDir("res");
|
in = inApk.getDir("res");
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public class ResValueFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ResValue factory(String value) {
|
public ResValue factory(String value) {
|
||||||
if (value.startsWith("res/")) {
|
if (value.startsWith("res/") && ! value.equalsIgnoreCase("res/")) {
|
||||||
return new ResFileValue(value);
|
return new ResFileValue(value);
|
||||||
}
|
}
|
||||||
return new ResStringValue(value);
|
return new ResStringValue(value);
|
||||||
|
@ -31,4 +31,8 @@
|
|||||||
<string-array name="issue_677" formatted="false">
|
<string-array name="issue_677" formatted="false">
|
||||||
<item>category=temp%temp%foo</item>
|
<item>category=temp%temp%foo</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
<string-array name="issue_329">
|
||||||
|
<item>res/</item>
|
||||||
|
<item>view/</item>
|
||||||
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user