From ca25a2694408ab7989fd107db7f8ff300fa3f779 Mon Sep 17 00:00:00 2001 From: Connor Tumbleson Date: Fri, 6 Apr 2018 10:31:28 -0400 Subject: [PATCH] fix: normalize paths for uncompressed assets & unknown files --- .../src/main/java/brut/androlib/Androlib.java | 10 ++++++---- .../java/brut/androlib/res/data/ResUnknownFiles.java | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java index 9e91fbf8..ccf2cdb4 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/Androlib.java @@ -652,7 +652,8 @@ public class Androlib { // loop through unknown files for (Map.Entry unknownFileInfo : files.entrySet()) { - String cleanedPath = BrutIO.sanitizeUnknownFile(unknownFileDir, unknownFileInfo.getKey()); + String normalizedPath = BrutIO.normalizePath(unknownFileInfo.getKey()); + String cleanedPath = BrutIO.sanitizeUnknownFile(unknownFileDir, normalizedPath); File inputFile = new File(unknownFileDir, cleanedPath); if (inputFile.isDirectory()) { continue; @@ -683,15 +684,16 @@ public class Androlib { File assetFileDir = new File(appDir, ASSET_DIRNAME); for (String asset : files) { - String cleanedPath = BrutIO.sanitizeUnknownFile(assetFileDir, asset); + String normalizedPath = BrutIO.normalizePath(asset); + String cleanedPath = BrutIO.sanitizeUnknownFile(assetFileDir, normalizedPath); File inputFile = new File(appDir, cleanedPath); if (inputFile.isDirectory()) { continue; } - LOGGER.fine(String.format("Copying uncompressed asset: %s", asset)); - ZipEntry newEntry = getStoredZipEntry(cleanedPath, inputFile); + LOGGER.fine(String.format("Copying uncompressed asset: %s", normalizedPath)); + ZipEntry newEntry = getStoredZipEntry(normalizedPath, inputFile); outputFile.putNextEntry(newEntry); BrutIO.copy(inputFile, outputFile); outputFile.closeEntry(); diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/ResUnknownFiles.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/ResUnknownFiles.java index 595c4343..a73362aa 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/ResUnknownFiles.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/ResUnknownFiles.java @@ -16,6 +16,7 @@ */ package brut.androlib.res.data; +import brut.util.BrutIO; import java.util.LinkedHashMap; import java.util.Map; @@ -27,7 +28,7 @@ public class ResUnknownFiles { private final Map mUnknownFiles = new LinkedHashMap<>(); public void addUnknownFileInfo(String file, String value) { - mUnknownFiles.put(file, value); + mUnknownFiles.put(BrutIO.normalizePath(file), value); } public Map getUnknownFiles() {