mirror of
https://github.com/revanced/Apktool.git
synced 2025-01-25 19:27:35 +01:00
Consistently encode unknown filenames to prevent cast error
This commit is contained in:
parent
9402bd90ec
commit
8232ee0ea8
@ -30,6 +30,7 @@ import brut.directory.*;
|
||||
import brut.util.BrutIO;
|
||||
import brut.util.OS;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
@ -258,7 +259,11 @@ public class Androlib {
|
||||
InputStream in = appDir.getDirectory().getFileInput("apktool.yml")
|
||||
) {
|
||||
Yaml yaml = new Yaml();
|
||||
return (Map<String, Object>) yaml.load(in);
|
||||
Map<String, Object> result = (Map<String, Object>) yaml.load(in);
|
||||
if (result.containsKey("unknownFiles")) {
|
||||
result.put("unknownFiles", getUnknownFiles(result));
|
||||
}
|
||||
return result;
|
||||
} catch (DirectoryException | IOException ex) {
|
||||
throw new AndrolibException(ex);
|
||||
}
|
||||
@ -737,6 +742,15 @@ public class Androlib {
|
||||
return files;
|
||||
}
|
||||
|
||||
private static Map<String, String> getUnknownFiles(Map<String, Object> meta) {
|
||||
Map<byte[], String> unknownFiles = (Map<byte[], String>) meta.get("unknownFiles");
|
||||
Map<String, String> result = new LinkedHashMap<>();
|
||||
for (Map.Entry<byte[], String> entry : unknownFiles.entrySet()) {
|
||||
result.put(new String(entry.getKey(), StandardCharsets.UTF_8), entry.getValue());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(Androlib.class.getName());
|
||||
|
||||
private final static String SMALI_DIRNAME = "smali";
|
||||
|
@ -377,7 +377,7 @@ public class ApkDecoder {
|
||||
}
|
||||
|
||||
private void putUnknownInfo(Map<String, Object> meta) throws AndrolibException {
|
||||
Map<String,String> info = mAndrolib.mResUnknownFiles.getUnknownFiles();
|
||||
Map<byte[], String> info = mAndrolib.mResUnknownFiles.getUnknownFiles();
|
||||
if (info.size() > 0) {
|
||||
meta.put("unknownFiles", info);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package brut.androlib.res.data;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -23,13 +24,13 @@ import java.util.Map;
|
||||
*/
|
||||
public class ResUnknownFiles {
|
||||
|
||||
private final Map<String, String> mUnknownFiles = new LinkedHashMap<String, String>();
|
||||
private final Map<byte[], String> mUnknownFiles = new LinkedHashMap<byte[], String>();
|
||||
|
||||
public void addUnknownFileInfo(String file, String value) {
|
||||
mUnknownFiles.put(file,value);
|
||||
mUnknownFiles.put(file.getBytes(StandardCharsets.UTF_8), value);
|
||||
}
|
||||
|
||||
public Map<String, String> getUnknownFiles() {
|
||||
public Map<byte[], String> getUnknownFiles() {
|
||||
return mUnknownFiles;
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ versionInfo:
|
||||
versionName: '1.0'
|
||||
compressionType: false
|
||||
unknownFiles:
|
||||
hidden.file: '8'
|
||||
stored.file: '0'
|
||||
unk_folder/unknown_file: '8'
|
||||
lib_bug603/bug603: '8'
|
||||
!!binary "aGlkZGVuLmZpbGU=": '8'
|
||||
!!binary "c3RvcmVkLmZpbGU=": '0'
|
||||
!!binary "dW5rX2ZvbGRlci91bmtub3duX2ZpbGU=": '8'
|
||||
!!binary "bGliX2J1ZzYwMy9idWc2MDM=": '8'
|
Loading…
x
Reference in New Issue
Block a user