正在查看: Mitra Bukalapak v2.55.0 应用的 WebContentUtils.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Mitra Bukalapak v2.55.0 应用的 WebContentUtils.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.braze.support;
import android.content.Context;
import bo.app.jg0;
import bo.app.kg0;
import bo.app.lg0;
import bo.app.mg0;
import bo.app.ng0;
import bo.app.og0;
import bo.app.pg0;
import bo.app.qg0;
import bo.app.rg0;
import bo.app.sg0;
import bo.app.tg0;
import bo.app.ug0;
import com.braze.support.BrazeLogger;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Locale;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import kotlin.Metadata;
@Metadata(d1 = {"\u0000,\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0004\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010$\n\u0002\b\b\bÇ\u0002\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u0015\u0010\u0016J\u001a\u0010\u0006\u001a\u0004\u0018\u00010\u00042\u0006\u0010\u0003\u001a\u00020\u00022\u0006\u0010\u0005\u001a\u00020\u0004H\u0007J\u0018\u0010\n\u001a\u00020\t2\u0006\u0010\u0007\u001a\u00020\u00042\u0006\u0010\b\u001a\u00020\u0002H\u0007J\u0010\u0010\r\u001a\u00020\u00022\u0006\u0010\f\u001a\u00020\u000bH\u0007J$\u0010\u0011\u001a\u00020\u00042\u0006\u0010\u000e\u001a\u00020\u00042\u0012\u0010\u0010\u001a\u000e\u0012\u0004\u0012\u00020\u0004\u0012\u0004\u0012\u00020\u00040\u000fH\u0007J\u0018\u0010\u0014\u001a\u00020\u00042\u0006\u0010\u0012\u001a\u00020\u00042\u0006\u0010\u0013\u001a\u00020\u0004H\u0007¨\u0006\u0017"}, d2 = {"Lcom/braze/support/WebContentUtils;", "", "Ljava/io/File;", "localDirectory", "", "remoteZipUrl", "getLocalHtmlUrlFromRemoteUrl", "unpackDirectory", "zipFile", "", "unpackZipIntoDirectory", "Landroid/content/Context;", "context", "getHtmlInAppMessageAssetCacheDirectory", "originalString", "", "remoteToLocalAssetMap", "replacePrefetchedUrlsWithLocalAssets", "intendedParentDirectory", "childFilePath", "validateChildFileExistsUnderParent", "<init>", "()V", "android-sdk-base_release"}, k = 1, mv = {1, 8, 0})
public final class WebContentUtils {
public static final WebContentUtils INSTANCE = new WebContentUtils();
private WebContentUtils() {
}
public static final File getHtmlInAppMessageAssetCacheDirectory(Context context) {
p64.h(context, "context");
return new File(context.getCacheDir().getPath() + "/braze-html-inapp-messages");
}
public static final String getLocalHtmlUrlFromRemoteUrl(File localDirectory, String remoteZipUrl) {
p64.h(localDirectory, "localDirectory");
p64.h(remoteZipUrl, "remoteZipUrl");
if (bu8.y(remoteZipUrl)) {
BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, BrazeLogger.Priority.W, (Throwable) null, jg0.a, 2, (Object) null);
return null;
}
String absolutePath = localDirectory.getAbsolutePath();
String valueOf = String.valueOf(IntentUtils.getRequestCode());
String str = absolutePath + '/' + valueOf;
BrazeLogger brazeLogger = BrazeLogger.INSTANCE;
WebContentUtils webContentUtils = INSTANCE;
BrazeLogger.brazelog$default(brazeLogger, webContentUtils, (BrazeLogger.Priority) null, (Throwable) null, new kg0(remoteZipUrl, str), 3, (Object) null);
try {
File file = (File) BrazeFileUtils.downloadFileToPath(str, remoteZipUrl, valueOf, ".zip").a();
BrazeLogger.brazelog$default(brazeLogger, webContentUtils, (BrazeLogger.Priority) null, (Throwable) null, new mg0(remoteZipUrl, str), 3, (Object) null);
if (unpackZipIntoDirectory(str, file)) {
BrazeLogger.brazelog$default(brazeLogger, webContentUtils, (BrazeLogger.Priority) null, (Throwable) null, new og0(str), 3, (Object) null);
return str;
}
BrazeLogger.brazelog$default(brazeLogger, webContentUtils, BrazeLogger.Priority.W, (Throwable) null, ng0.a, 2, (Object) null);
BrazeFileUtils.deleteFileOrDirectory(new File(str));
return null;
} catch (Exception e) {
BrazeLogger.INSTANCE.brazelog(INSTANCE, BrazeLogger.Priority.E, e, new lg0(remoteZipUrl));
BrazeFileUtils.deleteFileOrDirectory(new File(str));
return null;
}
}
public static final String replacePrefetchedUrlsWithLocalAssets(String originalString, Map<String, String> remoteToLocalAssetMap) {
p64.h(originalString, "originalString");
p64.h(remoteToLocalAssetMap, "remoteToLocalAssetMap");
String str = originalString;
for (Map.Entry<String, String> entry : remoteToLocalAssetMap.entrySet()) {
String value = entry.getValue();
if (new File(value).exists()) {
String key = entry.getKey();
if (bu8.R(value, "ab_triggers", false, 2, (Object) null)) {
String str2 = "https://iamcache.braze/ab_triggers" + ((String) bu8.J0(value, new String[]{"ab_triggers"}, false, 0, 6, (Object) null).get(1));
if (bu8.R(str, key, false, 2, (Object) null)) {
BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, (BrazeLogger.Priority) null, (Throwable) null, new qg0(key, str2), 3, (Object) null);
str = bu8.E(str, key, str2, false, 4, (Object) null);
}
}
} else {
BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, BrazeLogger.Priority.W, (Throwable) null, new pg0(value), 2, (Object) null);
}
}
return str;
}
public static final boolean unpackZipIntoDirectory(String unpackDirectory, File zipFile) {
p64.h(unpackDirectory, "unpackDirectory");
p64.h(zipFile, "zipFile");
if (bu8.y(unpackDirectory)) {
BrazeLogger.brazelog$default(BrazeLogger.INSTANCE, INSTANCE, BrazeLogger.Priority.I, (Throwable) null, rg0.a, 2, (Object) null);
return false;
}
new File(unpackDirectory).mkdirs();
try {
fl7 fl7Var = new fl7();
ZipInputStream zipInputStream = new ZipInputStream(new FileInputStream(zipFile));
try {
for (ZipEntry nextEntry = zipInputStream.getNextEntry(); nextEntry != null; nextEntry = zipInputStream.getNextEntry()) {
String name = nextEntry.getName();
p64.g(name, "zipEntry.name");
fl7Var.element = name;
Locale locale = Locale.US;
p64.g(locale, "US");
String lowerCase = name.toLowerCase(locale);
p64.g(lowerCase, "this as java.lang.String).toLowerCase(locale)");
if (!bu8.K(lowerCase, "__macosx", false, 2, (Object) null)) {
try {
String validateChildFileExistsUnderParent = validateChildFileExistsUnderParent(unpackDirectory, unpackDirectory + '/' + ((String) fl7Var.element));
if (nextEntry.isDirectory()) {
new File(validateChildFileExistsUnderParent).mkdirs();
} else {
try {
File parentFile = new File(validateChildFileExistsUnderParent).getParentFile();
if (parentFile != null) {
parentFile.mkdirs();
}
} catch (Exception e) {
BrazeLogger.INSTANCE.brazelog(INSTANCE, BrazeLogger.Priority.E, e, new sg0(fl7Var));
}
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(validateChildFileExistsUnderParent));
try {
qe0.b(zipInputStream, bufferedOutputStream, 0, 2, (Object) null);
os0.a(bufferedOutputStream, (Throwable) null);
} catch (Throwable th) {
try {
throw th;
} catch (Throwable th2) {
os0.a(bufferedOutputStream, th);
throw th2;
}
}
}
} catch (Exception e2) {
BrazeLogger.INSTANCE.brazelog(INSTANCE, BrazeLogger.Priority.E, e2, new tg0(fl7Var));
}
}
zipInputStream.closeEntry();
}
lm9 lm9Var = lm9.a;
os0.a(zipInputStream, (Throwable) null);
return true;
} finally {
}
} catch (Throwable th3) {
BrazeLogger.INSTANCE.brazelog(INSTANCE, BrazeLogger.Priority.E, th3, new ug0(zipFile, unpackDirectory));
return false;
}
}
public static final String validateChildFileExistsUnderParent(String intendedParentDirectory, String childFilePath) {
p64.h(intendedParentDirectory, "intendedParentDirectory");
p64.h(childFilePath, "childFilePath");
String canonicalPath = new File(intendedParentDirectory).getCanonicalPath();
String canonicalPath2 = new File(childFilePath).getCanonicalPath();
p64.g(canonicalPath2, "childFileCanonicalPath");
p64.g(canonicalPath, "parentCanonicalPath");
if (bu8.K(canonicalPath2, canonicalPath, false, 2, (Object) null)) {
return canonicalPath2;
}
throw new IllegalStateException("Invalid file with original path: " + childFilePath + " with canonical path: " + canonicalPath2 + " does not exist under intended parent with path: " + intendedParentDirectory + " and canonical path: " + canonicalPath);
}
}