Fix bug with processing and displaying long messages with mentions.

This commit is contained in:
Cody Henthorne
2021-08-06 13:19:44 -04:00
committed by GitHub
parent fc51c4940c
commit 570b4d7150
5 changed files with 18 additions and 21 deletions

View File

@@ -951,7 +951,6 @@ public final class SignalServiceContent {
for (SignalServiceProtos.DataMessage.BodyRange bodyRange : bodyRanges) {
if (bodyRange.hasMentionUuid()) {
try {
validateBodyRange(body, bodyRange);
mentions.add(new SignalServiceDataMessage.Mention(UuidUtil.parseOrThrow(bodyRange.getMentionUuid()), bodyRange.getStart(), bodyRange.getLength()));
} catch (IllegalArgumentException e) {
throw new ProtocolInvalidMessageException(new InvalidMessageException(e), null, 0);
@@ -966,16 +965,6 @@ public final class SignalServiceContent {
return mentions;
}
private static void validateBodyRange(String body, SignalServiceProtos.DataMessage.BodyRange bodyRange) throws ProtocolInvalidMessageException {
int incomingBodyLength = body != null ? body.length() : -1;
int start = bodyRange.hasStart() ? bodyRange.getStart() : -1;
int length = bodyRange.hasLength() ? bodyRange.getLength() : -1;
if (start < 0 || length < 0 || (start + length) > incomingBodyLength) {
throw new ProtocolInvalidMessageException(new InvalidMessageException("Incoming body range has out-of-bound range"), null, 0);
}
}
private static SignalServiceDataMessage.Sticker createSticker(SignalServiceProtos.DataMessage content) throws ProtocolInvalidMessageException {
if (!content.hasSticker() ||
!content.getSticker().hasPackId() ||