Фикс: зашифрованные ключи не отображаются как caption в фото viewer

decryptStoredMessageText возвращал зашифрованный текст при неудачной расшифровке.
Теперь возвращает пустую строку. Дополнительно: фильтр base64-like строк в caption viewer.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 01:43:38 +05:00
parent 655cc10a3e
commit 06f43b9d4e
2 changed files with 6 additions and 4 deletions

View File

@@ -637,7 +637,9 @@ fun ImageViewerScreen(
// ═══════════════════════════════════════════════════════════
// 📝 CAPTION BAR - Telegram-style снизу с анимацией
// ═══════════════════════════════════════════════════════════
val currentCaption = currentImage?.caption ?: ""
val rawCaption = currentImage?.caption ?: ""
// Filter out encrypted/garbled captions (base64 strings without spaces)
val currentCaption = if (rawCaption.isNotBlank() && !rawCaption.contains(' ') && rawCaption.length > 40 && rawCaption.matches(Regex("^[A-Za-z0-9+/=:]+$"))) "" else rawCaption
if (currentCaption.isNotEmpty()) {
AnimatedVisibility(
visible = showControls && animationState == 1 && !isClosing,

View File

@@ -1391,11 +1391,11 @@ private fun extractDownloadTagFromPreview(preview: String): String {
private fun decryptStoredMessageText(encryptedText: String, privateKey: String): String {
if (encryptedText.isBlank()) return ""
if (privateKey.isBlank()) return encryptedText
if (privateKey.isBlank()) return ""
return try {
CryptoManager.decryptWithPassword(encryptedText, privateKey) ?: encryptedText
CryptoManager.decryptWithPassword(encryptedText, privateKey) ?: ""
} catch (_: Exception) {
encryptedText
""
}
}