mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-11-04 10:19:47 +00:00
Handle oversized attachment dimensions (#2157)
This commit is contained in:
parent
49aaef000f
commit
1e878f3845
@ -313,8 +313,15 @@ public class SendCommand implements JsonRpcLocalCommand {
|
||||
+ dimension
|
||||
+ ") expected 'WIDTHxHEIGHT'");
|
||||
}
|
||||
dimensions.add(new Message.AttachmentDimensions(Integer.parseInt(matcher.group(1)),
|
||||
Integer.parseInt(matcher.group(2))));
|
||||
try {
|
||||
dimensions.add(new Message.AttachmentDimensions(Integer.parseInt(matcher.group(1)),
|
||||
Integer.parseInt(matcher.group(2))));
|
||||
} catch (NumberFormatException e) {
|
||||
throw new UserErrorException("Invalid attachment dimensions syntax ("
|
||||
+ dimension
|
||||
+ ") expected 'WIDTHxHEIGHT' with positive 32-bit integer values",
|
||||
e);
|
||||
}
|
||||
}
|
||||
return dimensions;
|
||||
}
|
||||
|
||||
@ -105,6 +105,20 @@ class SendCommandParsingTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsAttachmentDimensionsOutsideIntegerRange() {
|
||||
for (final var value : List.of("2147483648x1", "1x2147483648")) {
|
||||
assertThrows(UserErrorException.class, () -> send(namespace(List.of(value))), value);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void acceptsMaximumPositiveAttachmentDimensions() throws Exception {
|
||||
final var message = send(namespace(List.of("2147483647x2147483647")));
|
||||
assertEquals(List.of(new Message.AttachmentDimensions(Integer.MAX_VALUE, Integer.MAX_VALUE)),
|
||||
message.attachmentDimensions());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsMalformedBlurHashesBeforeSending() {
|
||||
// Wrong length for its size digit, an unknown size digit, too short.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user