Anki-Android
Anki-Android copied to clipboard
App crashes when importing APKG file with long name + emoji/unicode characters
Description
AnkiDroid is crashing when I try to import a deck (.apkg) that has a very long filename and includes Unicode characters, Cyrillic text, and emoji.
https://ankidroid.org/acra/app/1/bug/325541/report
java.lang.RuntimeException: Error importing apkg file
at a9.i.z(SourceFile:269)
at android.support.v4.media.session.b.E(SourceFile:70)
at O3.e4.z(SourceFile:17)
at C5.a.f(SourceFile:9)
at j7.E.run(SourceFile:117)
at A7.w.run(SourceFile:384)
at q7.j.run(SourceFile:3)
at q7.a.run(SourceFile:90)
Failed to shorten file: AnkiDroid exported flashcards: Медицина 🏥::Първи курс::Латински език с медицински термини-20251210223714.apkg
java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern : %8.
at j$.net.URLDecoder.decode(URLDecoder.java:214)
at j$.net.URLDecoder.decode(URLDecoder.java:142)
at com.ichi2.utils.ImportUtils$FileImporter.ensureValidLength(ImportUtils.kt:283)
at com.ichi2.utils.ImportUtils$FileImporter.handleContentProviderFile(ImportUtils.kt:239)
at com.ichi2.utils.ImportUtils$FileImporter.handleFileImportInternal(ImportUtils.kt:157)
at com.ichi2.utils.ImportUtils$FileImporter.handleFileImport(ImportUtils.kt:140)
at com.ichi2.utils.ImportUtils.handleFileImport(ImportUtils.kt:65)
at com.ichi2.anki.IntentHandler.handleFileImport(IntentHandler.kt:211)
at
How to Reproduce
- Create an .apkg file with a long name, for example:
AnkiDroid exported flashcards: Медицина 🏥::Първи курс::Латински език с медицински термини-20251210223714.apkg
- Import this file
Expected Result
The deck should import normally.
Great catch!
We should fall back to a usable default if we can't decode the name
And we should fix this issue
Working on this
usable default if we can't decode the name
either the hashsum, a timestamp, or a UUID