Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

App crashes when importing APKG file with long name + emoji/unicode characters

Open sanjaysargam opened this issue 4 weeks ago • 3 comments

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

  1. Create an .apkg file with a long name, for example:
AnkiDroid exported flashcards: Медицина 🏥::Първи курс::Латински език с медицински термини-20251210223714.apkg

  1. Import this file

Expected Result

The deck should import normally.

sanjaysargam avatar Dec 11 '25 08:12 sanjaysargam

Great catch!

We should fall back to a usable default if we can't decode the name

And we should fix this issue

david-allison avatar Dec 11 '25 09:12 david-allison

Working on this

sanjaysargam avatar Dec 11 '25 09:12 sanjaysargam

usable default if we can't decode the name

either the hashsum, a timestamp, or a UUID

BrayanDSO avatar Dec 11 '25 10:12 BrayanDSO