From 570f5741911dec47c55a08cfb0885c92ccd776f0 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Fri, 16 Jun 2023 20:27:55 -0500 Subject: [PATCH] Don't crash on bad number in sims --- .../siacs/conversations/entities/Message.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java index e50540c61..ce2953ecb 100644 --- a/src/main/java/eu/siacs/conversations/entities/Message.java +++ b/src/main/java/eu/siacs/conversations/entities/Message.java @@ -1275,14 +1275,18 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable if (file == null) file = mediaSharing.findChild("file", "urn:xmpp:jingle:apps:file-transfer:4"); if (file == null) file = mediaSharing.findChild("file", "urn:xmpp:jingle:apps:file-transfer:3"); if (file != null) { - String sizeS = file.findChildContent("size", file.getNamespace()); - if (sizeS != null) size = new Long(sizeS); - String widthS = file.findChildContent("width", "https://schema.org/"); - if (widthS != null) width = parseInt(widthS); - String heightS = file.findChildContent("height", "https://schema.org/"); - if (heightS != null) height = parseInt(heightS); - String durationS = file.findChildContent("duration", "https://schema.org/"); - if (durationS != null) runtime = (int)(Duration.parse(durationS).toMillis() / 1000L); + try { + String sizeS = file.findChildContent("size", file.getNamespace()); + if (sizeS != null) size = new Long(sizeS); + String widthS = file.findChildContent("width", "https://schema.org/"); + if (widthS != null) width = parseInt(widthS); + String heightS = file.findChildContent("height", "https://schema.org/"); + if (heightS != null) height = parseInt(heightS); + String durationS = file.findChildContent("duration", "https://schema.org/"); + if (durationS != null) runtime = (int)(Duration.parse(durationS).toMillis() / 1000L); + } catch (final NumberFormatException e) { + Log.w(Config.LOGTAG, "Trouble parsing as number: " + e); + } } final Element sources = mediaSharing.findChild("sources", "urn:xmpp:sims:1"); -- 2.45.2