Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: mapping between unknown chars & valid chars #1460

Open
AhmadKahlid opened this issue Mar 27, 2017 · 4 comments
Open

Windows: mapping between unknown chars & valid chars #1460

AhmadKahlid opened this issue Mar 27, 2017 · 4 comments

Comments

@AhmadKahlid
Copy link

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
@iBotPeaches iBotPeaches changed the title Exception in thread "main" brut.androlib.AndrolibException: brut.directory.DirectoryException: Error copying file Windows: mapping between unknown chars & valid chars Mar 27, 2017
@iBotPeaches
Copy link
Owner

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.

@jpstotz
Copy link

jpstotz commented Nov 27, 2021

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.

@ghost
Copy link

ghost commented Nov 29, 2021

This would be all solved if Windows ever supported EXT drives

@jpstotz
Copy link

jpstotz commented Nov 29, 2021

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants