mirror of
https://github.com/revanced/ARSCLib.git
synced 2025-04-29 22:04:25 +02:00
sanitize resource files optionally
This commit is contained in:
parent
9d0a62444c
commit
dd5233f13c
@ -25,24 +25,41 @@ public class PathSanitizer {
|
||||
private final ApkModule apkModule;
|
||||
private APKLogger apkLogger;
|
||||
private final Set<String> mSanitizedPaths;
|
||||
public PathSanitizer(ApkModule apkModule){
|
||||
private final boolean sanitizeResourceFiles;
|
||||
public PathSanitizer(ApkModule apkModule, boolean sanitizeResourceFiles){
|
||||
this.apkModule = apkModule;
|
||||
this.apkLogger = apkModule.getApkLogger();
|
||||
this.mSanitizedPaths = new HashSet<>();
|
||||
this.sanitizeResourceFiles = sanitizeResourceFiles;
|
||||
}
|
||||
public PathSanitizer(ApkModule apkModule){
|
||||
this(apkModule, false);
|
||||
}
|
||||
public void sanitize(){
|
||||
mSanitizedPaths.clear();
|
||||
logMessage("Sanitizing paths ...");
|
||||
List<ResFile> resFileList = apkModule.listResFiles();
|
||||
for(ResFile resFile:resFileList){
|
||||
sanitize(resFile);
|
||||
}
|
||||
sanitizeResFiles();
|
||||
List<InputSource> sourceList = apkModule.getApkArchive().listInputSources();
|
||||
for(InputSource inputSource:sourceList){
|
||||
sanitize(inputSource, 1, false);
|
||||
}
|
||||
logMessage("DONE = "+mSanitizedPaths.size());
|
||||
}
|
||||
private void sanitizeResFiles(){
|
||||
boolean sanitizeRes = this.sanitizeResourceFiles;
|
||||
Set<String> sanitizedPaths = this.mSanitizedPaths;
|
||||
if(sanitizeRes){
|
||||
logMessage("Sanitizing resource files ...");
|
||||
}
|
||||
List<ResFile> resFileList = apkModule.listResFiles();
|
||||
for(ResFile resFile:resFileList){
|
||||
if(sanitizeRes){
|
||||
sanitize(resFile);
|
||||
}else {
|
||||
sanitizedPaths.add(resFile.getFilePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
private void sanitize(ResFile resFile){
|
||||
InputSource inputSource = resFile.getInputSource();
|
||||
String replace = sanitize(inputSource, 3, true);
|
||||
@ -178,6 +195,6 @@ public class PathSanitizer {
|
||||
|| (ch >= 'a' && ch <= 'z');
|
||||
}
|
||||
|
||||
private static final int MAX_NAME_LENGTH = 50;
|
||||
private static final int MAX_NAME_LENGTH = 75;
|
||||
private static final int MAX_PATH_LENGTH = 100;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user