From e9e40cb13ea942b148b259c083fb3364a0cd90ea Mon Sep 17 00:00:00 2001 From: DrKLO Date: Sat, 9 Dec 2017 03:45:38 +0300 Subject: [PATCH] bug fixes --- TMessagesProj/build.gradle | 2 +- .../jni/tgnet/ConnectionsManager.cpp | 2 +- TMessagesProj/jni/tgnet/NativeByteBuffer.cpp | 6 +++--- .../org/telegram/messenger/BuildVars.java | 2 +- .../org/telegram/messenger/FileLoader.java | 19 ++++++++++++------- .../telegram/messenger/MessagesStorage.java | 2 +- .../messenger/MusicPlayerService.java | 12 ++++++------ 7 files changed, 25 insertions(+), 20 deletions(-) diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index deae20092..34fa7e59d 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -91,7 +91,7 @@ android { } } - defaultConfig.versionCode = 1154 + defaultConfig.versionCode = 1155 sourceSets.debug { manifest.srcFile 'config/debug/AndroidManifest.xml' diff --git a/TMessagesProj/jni/tgnet/ConnectionsManager.cpp b/TMessagesProj/jni/tgnet/ConnectionsManager.cpp index 5d5d55195..6772aed15 100644 --- a/TMessagesProj/jni/tgnet/ConnectionsManager.cpp +++ b/TMessagesProj/jni/tgnet/ConnectionsManager.cpp @@ -1289,12 +1289,12 @@ void ConnectionsManager::processServerResponse(TLObject *message, int64_t messag networkMessage->message->bytes = request->getObjectSize(); networkMessage->message->body = std::unique_ptr(request); networkMessage->message->seqno = connection->generateMessageSeqNo(false); + resendRequests[networkMessage->message->msg_id] = response->answer_msg_id; std::vector> array; array.push_back(std::unique_ptr(networkMessage)); sendMessagesToConnection(array, connection, false); - resendRequests[networkMessage->message->msg_id] = response->answer_msg_id; } else if (confirm) { connection->addMessageToConfirm(response->answer_msg_id); } diff --git a/TMessagesProj/jni/tgnet/NativeByteBuffer.cpp b/TMessagesProj/jni/tgnet/NativeByteBuffer.cpp index 19f36f067..d182713bf 100644 --- a/TMessagesProj/jni/tgnet/NativeByteBuffer.cpp +++ b/TMessagesProj/jni/tgnet/NativeByteBuffer.cpp @@ -476,7 +476,7 @@ int32_t NativeByteBuffer::readBigInt32(bool *error) { } int64_t NativeByteBuffer::readInt64(bool *error) { - if (_position + 4 > _limit) { + if (_position + 8 > _limit) { if (error != nullptr) { *error = true; } @@ -521,7 +521,7 @@ bool NativeByteBuffer::readBool(bool *error) { } void NativeByteBuffer::readBytes(uint8_t *b, uint32_t length, bool *error) { - if (_position + length > _limit) { + if (length > _limit - _position) { if (error != nullptr) { *error = true; } @@ -533,7 +533,7 @@ void NativeByteBuffer::readBytes(uint8_t *b, uint32_t length, bool *error) { } ByteArray *NativeByteBuffer::readBytes(uint32_t length, bool *error) { - if (_position + length > _limit) { + if (length > _limit - _position) { if (error != nullptr) { *error = true; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index 560090b99..b3986ef30 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -11,7 +11,7 @@ package org.telegram.messenger; public class BuildVars { public static boolean DEBUG_VERSION = false; public static boolean DEBUG_PRIVATE_VERSION = false; - public static int BUILD_VERSION = 1154; + public static int BUILD_VERSION = 1155; public static String BUILD_VERSION_STRING = "4.6"; public static int APP_ID = 0; //obtain your own APP_ID at https://core.telegram.org/api/obtaining_api_id public static String APP_HASH = ""; //obtain your own APP_HASH at https://core.telegram.org/api/obtaining_api_id diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java index 11bdcc125..a82069978 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java @@ -808,18 +808,23 @@ public class FileLoader { } public static String getDocumentFileName(TLRPC.Document document) { + String fileName = null; if (document != null) { if (document.file_name != null) { - return document.file_name; - } - for (int a = 0; a < document.attributes.size(); a++) { - TLRPC.DocumentAttribute documentAttribute = document.attributes.get(a); - if (documentAttribute instanceof TLRPC.TL_documentAttributeFilename) { - return documentAttribute.file_name; + fileName = document.file_name; + } else { + for (int a = 0; a < document.attributes.size(); a++) { + TLRPC.DocumentAttribute documentAttribute = document.attributes.get(a); + if (documentAttribute instanceof TLRPC.TL_documentAttributeFilename) { + fileName = documentAttribute.file_name; + } } } } - return ""; + if (fileName != null) { + fileName = fileName.replaceAll("[\u0001-\u001f<>:\"/\\\\|?*\u007f]+", "").trim(); + } + return fileName != null ? fileName : ""; } public static String getExtensionByMime(String mime) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java index 793912fae..0cf3e7b40 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java @@ -4863,7 +4863,7 @@ public class MessagesStorage { mentionsIdsMap.put(messageId, message.dialog_id); } - if (!MessageObject.isOut(message) && (message.id > 0 || MessageObject.isUnread(message))) { + if (!(message.action instanceof TLRPC.TL_messageActionHistoryClear) && !MessageObject.isOut(message) && (message.id > 0 || MessageObject.isUnread(message))) { Integer currentMaxId = dialogsReadMax.get(message.dialog_id); if (currentMaxId == null) { SQLiteCursor cursor = database.queryFinalized("SELECT inbox_max FROM dialogs WHERE did = " + message.dialog_id); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MusicPlayerService.java b/TMessagesProj/src/main/java/org/telegram/messenger/MusicPlayerService.java index f2521fd6d..98b298bb8 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MusicPlayerService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MusicPlayerService.java @@ -193,17 +193,17 @@ public class MusicPlayerService extends Service implements NotificationCenter.No if (MediaController.getInstance().isDownloadingCurrentMessage()) { playbackState.setState(PlaybackState.STATE_BUFFERING, 0, 1).setActions(0); - bldr.addAction(new Notification.Action.Builder(R.drawable.ic_action_previous, null, pendingPrev).build()) - .addAction(new Notification.Action.Builder(R.drawable.loading_animation2, null, null).build()) - .addAction(new Notification.Action.Builder(R.drawable.ic_action_next, null, pendingNext).build()); + bldr.addAction(new Notification.Action.Builder(R.drawable.ic_action_previous, "", pendingPrev).build()) + .addAction(new Notification.Action.Builder(R.drawable.loading_animation2, "", null).build()) + .addAction(new Notification.Action.Builder(R.drawable.ic_action_next, "", pendingNext).build()); } else { playbackState.setState(isPlaying ? PlaybackState.STATE_PLAYING : PlaybackState.STATE_PAUSED, MediaController.getInstance().getPlayingMessageObject().audioProgressSec * 1000L, isPlaying ? 1 : 0) .setActions(PlaybackState.ACTION_PLAY_PAUSE | PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PAUSE | PlaybackState.ACTION_SKIP_TO_PREVIOUS | PlaybackState.ACTION_SKIP_TO_NEXT); - bldr.addAction(new Notification.Action.Builder(R.drawable.ic_action_previous, null, pendingPrev).build()) - .addAction(new Notification.Action.Builder(isPlaying ? R.drawable.ic_action_pause : R.drawable.ic_action_play, null, pendingPlaypause).build()) - .addAction(new Notification.Action.Builder(R.drawable.ic_action_next, null, pendingNext).build()); + bldr.addAction(new Notification.Action.Builder(R.drawable.ic_action_previous, "", pendingPrev).build()) + .addAction(new Notification.Action.Builder(isPlaying ? R.drawable.ic_action_pause : R.drawable.ic_action_play, "", pendingPlaypause).build()) + .addAction(new Notification.Action.Builder(R.drawable.ic_action_next, "", pendingNext).build()); } mediaSession.setPlaybackState(playbackState.build());