Remove emoji from plaintext export names.

This commit is contained in:
Greyson Parrelli
2026-07-15 16:43:47 -04:00
parent 07ca23ceae
commit 90cba056f1
2 changed files with 62 additions and 1 deletions
@@ -44,6 +44,18 @@ object PlaintextExportRepository {
private val TAG = Log.tag(PlaintextExportRepository::class.java)
private const val BATCH_SIZE = 500
private val EMOJI_REGEX = Regex(
"[" +
"\\x{1F000}-\\x{1FAFF}" +
"\\x{2600}-\\x{27BF}" +
"\\x{2300}-\\x{23FF}" +
"\\x{2B00}-\\x{2BFF}" +
"\\x{FE00}-\\x{FE0F}" +
"\\x{200D}" +
"\\x{20E3}" +
"]"
)
fun export(
context: Context,
threadId: Long,
@@ -435,7 +447,12 @@ object PlaintextExportRepository {
@VisibleForTesting
internal fun sanitizeFileName(name: String): String {
val sanitized = name.replace(Regex("[\\\\/:*?\"<>|]"), "_").trim().take(100)
val sanitized = name
.replace(EMOJI_REGEX, "")
.replace(Regex("[\\\\/:*?\"<>|]"), "_")
.replace(Regex("\\s+"), " ")
.trim()
.take(100)
return if (sanitized.isEmpty() || sanitized.all { it == '.' }) "chat" else sanitized
}