From 37e4c0a105f20e041e4f6fc454376775dc0fb88d Mon Sep 17 00:00:00 2001 From: Hardcore Sushi Date: Sun, 25 Jul 2021 14:26:59 +0200 Subject: [PATCH] Handle special characters in file names --- .../hardcore/aira/background_service/AIRAService.kt | 1 - .../sushi/hardcore/aira/background_service/Protocol.kt | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/sushi/hardcore/aira/background_service/AIRAService.kt b/app/src/main/java/sushi/hardcore/aira/background_service/AIRAService.kt index 79a0966..cf0bc83 100644 --- a/app/src/main/java/sushi/hardcore/aira/background_service/AIRAService.kt +++ b/app/src/main/java/sushi/hardcore/aira/background_service/AIRAService.kt @@ -400,7 +400,6 @@ class AIRAService : Service() { ) .build() ) - } notificationManager.notify(notificationIdManager.getMessageNotificationId(sessionId), notificationBuilder.build()) } diff --git a/app/src/main/java/sushi/hardcore/aira/background_service/Protocol.kt b/app/src/main/java/sushi/hardcore/aira/background_service/Protocol.kt index c0d97bb..bbdf804 100644 --- a/app/src/main/java/sushi/hardcore/aira/background_service/Protocol.kt +++ b/app/src/main/java/sushi/hardcore/aira/background_service/Protocol.kt @@ -1,6 +1,5 @@ package sushi.hardcore.aira.background_service -import sushi.hardcore.aira.widgets.Avatar import java.nio.ByteBuffer class Protocol { @@ -38,15 +37,17 @@ class Protocol { } fun newFile(fileName: String, buffer: ByteArray): ByteArray { - return byteArrayOf(FILE)+ByteBuffer.allocate(2).putShort(fileName.length.toShort()).array()+fileName.toByteArray()+buffer + val fileNameBytes = fileName.toByteArray() + return byteArrayOf(FILE)+ByteBuffer.allocate(2).putShort(fileNameBytes.size.toShort()).array()+fileNameBytes+buffer } fun askLargeFiles(files: List): ByteArray { var buff = byteArrayOf(ASK_LARGE_FILES) for (file in files) { + val fileName = file.fileName.toByteArray() buff += ByteBuffer.allocate(8).putLong(file.fileSize).array() - buff += ByteBuffer.allocate(2).putShort(file.fileName.length.toShort()).array() - buff += file.fileName.toByteArray() + buff += ByteBuffer.allocate(2).putShort(fileName.size.toShort()).array() + buff += fileName } return buff }