Apktool icon indicating copy to clipboard operation
Apktool copied to clipboard

Windows: mapping between unknown chars & valid chars

Open AhmadKahlid opened this issue 8 years ago • 4 comments
trafficstars

Information

  1. **Apktool Version (apktool -version) - 2.2.2
  2. **Operating System (Mac, Linux, Windows) - Windows
  3. **APK From? (Playstore, ROM, Other) - URL: http://files.nabstudio.com/mangarock/mangarock-definitive-v1.9.9-RELEASE.apk?cfcache=1

Stacktrace/Logcat

>apktool d "G:\mangarock.apk" --keep-broken-res -f
I: Using Apktool 2.2.2 on mangarock.apk
I: Loading resource table...
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f070000
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f070001
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f070002
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f070003
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f070004
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f070005
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f070006
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f070007
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f070008
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f070009
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f07000a
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f07000b
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f07000c
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f07000d
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f07000e
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f07000f
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f070010
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f070011
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f070012
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f07003d
W: Duplicate Resource Detected. Ignoring duplicate: string-sr/APKTOOL_DUMMYVAL_0x7f07003e
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: ~\AppData\Local\apktool\framework\1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Baksmaling classes2.dex...
I: Copying assets and libs...
I: Copying unknown files...
Exception in thread "main" brut.androlib.AndrolibException: brut.directory.DirectoryException: Error copying file: ??♀.xml
        at brut.androlib.Androlib.decodeUnknownFiles(Androlib.java:217)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:158)
        at brut.apktool.Main.cmdDecode(Main.java:166)
        at brut.apktool.Main.main(Main.java:81)
Caused by: brut.directory.DirectoryException: Error copying file: ??♀.xml
        at brut.directory.DirUtil.copyToDir(DirUtil.java:88)
        at brut.directory.AbstractDirectory.copyToDir(AbstractDirectory.java:207
)
        at brut.androlib.Androlib.decodeUnknownFiles(Androlib.java:210)
        ... 3 more
Caused by: java.io.FileNotFoundException: \mangarock\unknown\??♀.xml (The filename, directory name, or volume label syntax is incorrect)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.<init>(Unknown Source)
        at java.io.FileOutputStream.<init>(Unknown Source)
        at brut.directory.DirUtil.copyToDir(DirUtil.java:84)
        ... 5 more

Steps to Reproduce

  1. apktool d "G:\mangarock.apk" --keep-broken-res -f

APK

http://files.nabstudio.com/mangarock/mangarock-definitive-v1.9.9-RELEASE.apk?cfcache=1

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? YES
  2. If you are trying to install a modified apk, did you resign it? N/A
  3. Are you using the latest apktool version? YES

AhmadKahlid avatar Mar 27 '17 10:03 AhmadKahlid

This is a duplicate of #1314 , but I closed that one for being a Windows problem. There is no short term fix for this. The work required to create a lookup table of filenames, yet save them back into the apk as the original string is a ton of work.

So that is why I closed the report, use unix/mac until then.

iBotPeaches avatar Mar 27 '17 12:03 iBotPeaches

The common and easy way would be to build a white-list of characters which are supported on all platforms/current platform in file-names. Additionally a blacklist of forbidden file-names can be created.

Everything that does not match the whitelist or terms from the blacklist is escaped:

For example:

  • & is escaped to &amp;
  • [unicode] characters could be URL encoded © -> &#169;
  • forbidden file names like CON -> &!CON;

Then you don't have to store a mapping somewhere. For compatibility with decompiled directories created by older apktool versions you can add a flag in apktool.yml that enabled/disabled escaping and if the option is missing this means escaping is disabled.

And when running on Windows for solving the case sensitivity problem on NTFS drives you could run fsutil.exe file SetCaseSensitiveInfo C:\folder\path enable to enable case sensitivity of the extraction directory.

jpstotz avatar Nov 27 '21 13:11 jpstotz

This would be all solved if Windows ever supported EXT drives

ghost avatar Nov 29 '21 16:11 ghost

@KarmaMod I don't see a relation between the file-system and disallowed files like CON. Even if Windows would support EXT drives those files will most likely still be unsupported.

jpstotz avatar Nov 29 '21 16:11 jpstotz