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 final ApkModule apkModule;
|
||||||
private APKLogger apkLogger;
|
private APKLogger apkLogger;
|
||||||
private final Set<String> mSanitizedPaths;
|
private final Set<String> mSanitizedPaths;
|
||||||
public PathSanitizer(ApkModule apkModule){
|
private final boolean sanitizeResourceFiles;
|
||||||
|
public PathSanitizer(ApkModule apkModule, boolean sanitizeResourceFiles){
|
||||||
this.apkModule = apkModule;
|
this.apkModule = apkModule;
|
||||||
this.apkLogger = apkModule.getApkLogger();
|
this.apkLogger = apkModule.getApkLogger();
|
||||||
this.mSanitizedPaths = new HashSet<>();
|
this.mSanitizedPaths = new HashSet<>();
|
||||||
|
this.sanitizeResourceFiles = sanitizeResourceFiles;
|
||||||
|
}
|
||||||
|
public PathSanitizer(ApkModule apkModule){
|
||||||
|
this(apkModule, false);
|
||||||
}
|
}
|
||||||
public void sanitize(){
|
public void sanitize(){
|
||||||
mSanitizedPaths.clear();
|
mSanitizedPaths.clear();
|
||||||
logMessage("Sanitizing paths ...");
|
logMessage("Sanitizing paths ...");
|
||||||
List<ResFile> resFileList = apkModule.listResFiles();
|
sanitizeResFiles();
|
||||||
for(ResFile resFile:resFileList){
|
|
||||||
sanitize(resFile);
|
|
||||||
}
|
|
||||||
List<InputSource> sourceList = apkModule.getApkArchive().listInputSources();
|
List<InputSource> sourceList = apkModule.getApkArchive().listInputSources();
|
||||||
for(InputSource inputSource:sourceList){
|
for(InputSource inputSource:sourceList){
|
||||||
sanitize(inputSource, 1, false);
|
sanitize(inputSource, 1, false);
|
||||||
}
|
}
|
||||||
logMessage("DONE = "+mSanitizedPaths.size());
|
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){
|
private void sanitize(ResFile resFile){
|
||||||
InputSource inputSource = resFile.getInputSource();
|
InputSource inputSource = resFile.getInputSource();
|
||||||
String replace = sanitize(inputSource, 3, true);
|
String replace = sanitize(inputSource, 3, true);
|
||||||
@ -178,6 +195,6 @@ public class PathSanitizer {
|
|||||||
|| (ch >= 'a' && ch <= 'z');
|
|| (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;
|
private static final int MAX_PATH_LENGTH = 100;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user