Limit received MMS message length to 5000
This is to avoid ANRs just in case there are very large text messages in the system (either added on purpose or sent by someone else to trigger ANRs in the user's device)
This commit is contained in:
parent
2a9b5b6d85
commit
20999d70e5
2 changed files with 6 additions and 1 deletions
|
|
@ -54,6 +54,7 @@ import org.fossify.messages.databases.MessagesDatabase
|
||||||
import org.fossify.messages.helpers.AttachmentUtils.parseAttachmentNames
|
import org.fossify.messages.helpers.AttachmentUtils.parseAttachmentNames
|
||||||
import org.fossify.messages.helpers.Config
|
import org.fossify.messages.helpers.Config
|
||||||
import org.fossify.messages.helpers.FILE_SIZE_NONE
|
import org.fossify.messages.helpers.FILE_SIZE_NONE
|
||||||
|
import org.fossify.messages.helpers.MAX_MESSAGE_LENGTH
|
||||||
import org.fossify.messages.helpers.MESSAGES_LIMIT
|
import org.fossify.messages.helpers.MESSAGES_LIMIT
|
||||||
import org.fossify.messages.helpers.NotificationHelper
|
import org.fossify.messages.helpers.NotificationHelper
|
||||||
import org.fossify.messages.helpers.generateRandomId
|
import org.fossify.messages.helpers.generateRandomId
|
||||||
|
|
@ -476,7 +477,10 @@ fun Context.getMmsAttachment(id: Long, getImageResolutions: Boolean): MessageAtt
|
||||||
val partId = cursor.getLongValue(Mms._ID)
|
val partId = cursor.getLongValue(Mms._ID)
|
||||||
val mimetype = cursor.getStringValue(Mms.Part.CONTENT_TYPE)
|
val mimetype = cursor.getStringValue(Mms.Part.CONTENT_TYPE)
|
||||||
if (mimetype == "text/plain") {
|
if (mimetype == "text/plain") {
|
||||||
messageAttachment.text = cursor.getStringValue(Mms.Part.TEXT) ?: ""
|
messageAttachment.text = cursor
|
||||||
|
.getStringValue(Mms.Part.TEXT)
|
||||||
|
?.take(MAX_MESSAGE_LENGTH)
|
||||||
|
.orEmpty()
|
||||||
} else if (mimetype.startsWith("image/") || mimetype.startsWith("video/")) {
|
} else if (mimetype.startsWith("image/") || mimetype.startsWith("video/")) {
|
||||||
val fileUri = Uri.withAppendedPath(uri, partId.toString())
|
val fileUri = Uri.withAppendedPath(uri, partId.toString())
|
||||||
var width = 0
|
var width = 0
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ const val FILE_SIZE_1_MB = 1_048_576L
|
||||||
const val FILE_SIZE_2_MB = 2_097_152L
|
const val FILE_SIZE_2_MB = 2_097_152L
|
||||||
|
|
||||||
const val MESSAGES_LIMIT = 30
|
const val MESSAGES_LIMIT = 30
|
||||||
|
const val MAX_MESSAGE_LENGTH = 5000
|
||||||
|
|
||||||
// intent launch request codes
|
// intent launch request codes
|
||||||
const val PICK_PHOTO_INTENT = 42
|
const val PICK_PHOTO_INTENT = 42
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue