From 32577b23bcfd290b969592ab0460074cb611e2da Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Thu, 1 Sep 2022 10:09:08 +0200 Subject: [PATCH 1/4] bump version to beta series --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 98ea3b48b..94a0f4994 100644 --- a/build.gradle +++ b/build.gradle @@ -92,8 +92,8 @@ android { useLibrary 'org.apache.http.legacy' defaultConfig { - versionCode 635 - versionName "1.32.0" + versionCode 636 + versionName "1.33.0" applicationId "com.b44t.messenger" multiDexEnabled true From 07a224d6ae267ee710b178f50ea73e14b2ec4c58 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Mon, 5 Sep 2022 11:46:16 +0200 Subject: [PATCH 2/4] update deltachat-core-rust submodule to 'restricted webxdc internet access (#3516)' --- jni/deltachat-core-rust | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jni/deltachat-core-rust b/jni/deltachat-core-rust index b2b22c8b8..949370ad6 160000 --- a/jni/deltachat-core-rust +++ b/jni/deltachat-core-rust @@ -1 +1 @@ -Subproject commit b2b22c8b85d295e394b8beca72ceed5a0508e4d9 +Subproject commit 949370ad63ceee89c0d8677aff9eeb17d5a5811d From e39842c692452079e8f589af9d7ad615e8b88680 Mon Sep 17 00:00:00 2001 From: bjoern Date: Tue, 6 Sep 2022 11:22:08 +0200 Subject: [PATCH 3/4] restricted webxdc internet access (#2378) * allow webxdc internet access if the corresponding flag is set by core * do not intercept requests when internetAccess is granted --- .../securesms/WebxdcActivity.java | 46 +++++++++++-------- .../securesms/util/JsonUtils.java | 8 ++++ 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/org/thoughtcrime/securesms/WebxdcActivity.java b/src/org/thoughtcrime/securesms/WebxdcActivity.java index 23316a21f..015299b9e 100644 --- a/src/org/thoughtcrime/securesms/WebxdcActivity.java +++ b/src/org/thoughtcrime/securesms/WebxdcActivity.java @@ -48,8 +48,7 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE private DcMsg dcAppMsg; private String baseURL; private String sourceCodeUrl = ""; - - + private boolean internetAccess = false; public static void openWebxdcActivity(Context context, DcMsg instance) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { @@ -115,10 +114,13 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE // also a random-id is not that useful for debugging) this.baseURL = "https://acc" + dcContext.getAccountId() + "-msg" + appMessageId + ".localhost"; + final JSONObject info = this.dcAppMsg.getWebxdcInfo(); + internetAccess = JsonUtils.optBoolean(info, "internet_access"); + WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setAllowFileAccess(false); - webSettings.setBlockNetworkLoads(true); + webSettings.setBlockNetworkLoads(!internetAccess); webSettings.setAllowContentAccess(false); webSettings.setGeolocationEnabled(false); webSettings.setAllowFileAccessFromFileURLs(false); @@ -128,7 +130,13 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE webView.addJavascriptInterface(new InternalJSApi(), "InternalJSApi"); webView.loadUrl(this.baseURL + "/index.html"); - updateTitleAndMenu(); + + Util.runOnAnyBackgroundThread(() -> { + final DcChat chat = dcContext.getChat(dcAppMsg.getChatId()); + Util.runOnMain(() -> { + updateTitleAndMenu(info, chat); + }); + }); } @Override @@ -188,6 +196,9 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE } else { byte[] blob = this.dcAppMsg.getWebxdcBlob(path); if (blob == null) { + if (internetAccess) { + return null; // do not intercept request + } throw new Exception("\"" + path + "\" not found"); } String ext = MediaUtil.getFileExtensionFromUrl(path); @@ -216,26 +227,25 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE Log.i(TAG, "handleEvent"); webView.loadUrl("javascript:window.__webxdcUpdate();"); } else if ((eventId == DcContext.DC_EVENT_MSGS_CHANGED && event.getData2Int() == dcAppMsg.getId())) { - updateTitleAndMenu(); + Util.runOnAnyBackgroundThread(() -> { + final JSONObject info = dcAppMsg.getWebxdcInfo(); + final DcChat chat = dcContext.getChat(dcAppMsg.getChatId()); + Util.runOnMain(() -> { + updateTitleAndMenu(info, chat); + }); + }); } } - private void updateTitleAndMenu() { - Util.runOnAnyBackgroundThread(() -> { - final JSONObject info = this.dcAppMsg.getWebxdcInfo(); + private void updateTitleAndMenu(JSONObject info, DcChat chat) { final String docName = JsonUtils.optString(info, "document"); final String xdcName = JsonUtils.optString(info, "name"); - final String chatName = WebxdcActivity.this.dcContext.getChat(WebxdcActivity.this.dcAppMsg.getChatId()).getName(); final String currSourceCodeUrl = JsonUtils.optString(info, "source_code_url"); - - Util.runOnMain(() -> { - getSupportActionBar().setTitle((docName.isEmpty() ? xdcName : docName) + " – " + chatName); - if (!sourceCodeUrl.equals(currSourceCodeUrl)) { - sourceCodeUrl = currSourceCodeUrl; - invalidateOptionsMenu(); - } - }); - }); + getSupportActionBar().setTitle((docName.isEmpty() ? xdcName : docName) + " – " + chat.getName()); + if (!sourceCodeUrl.equals(currSourceCodeUrl)) { + sourceCodeUrl = currSourceCodeUrl; + invalidateOptionsMenu(); + } } public static void addToHomeScreen(Activity activity, int msgId) { diff --git a/src/org/thoughtcrime/securesms/util/JsonUtils.java b/src/org/thoughtcrime/securesms/util/JsonUtils.java index d87691fc0..e868566de 100644 --- a/src/org/thoughtcrime/securesms/util/JsonUtils.java +++ b/src/org/thoughtcrime/securesms/util/JsonUtils.java @@ -54,6 +54,14 @@ public class JsonUtils { } } + public static boolean optBoolean(JSONObject obj, String name) { + try { + return obj.optBoolean(name); + } catch(Exception e) { + return false; + } + } + public static class SaneJSONObject { private final JSONObject delegate; From 33a543328fb3f22adf8b48e639aab508ea316a66 Mon Sep 17 00:00:00 2001 From: bjoern Date: Thu, 8 Sep 2022 17:46:34 +0200 Subject: [PATCH 4/4] Revert "create adaptive shortcuts" (#2379) * Revert "create adaptive shortcuts" This reverts commit 35dd8c905b7ff182c92a1bcfcfe03a97edecbb00. The cut out is not the largets possible circle inside the square icon (as for group images or avatars, diameter==height) but a much smaller circle (diameter==~0.6*height), resulting in too many information being left out. Therefore, it is better to leave icon layout to the OS. (to get an idea about the amount of cut out, see a circular logo, eg. the hextris one) * add comment why not to use createWithAdaptiveBitmap() --- src/org/thoughtcrime/securesms/WebxdcActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/WebxdcActivity.java b/src/org/thoughtcrime/securesms/WebxdcActivity.java index 015299b9e..352473a06 100644 --- a/src/org/thoughtcrime/securesms/WebxdcActivity.java +++ b/src/org/thoughtcrime/securesms/WebxdcActivity.java @@ -264,7 +264,7 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE ShortcutInfoCompat shortcutInfoCompat = new ShortcutInfoCompat.Builder(context, "xdc-" + dcContext.getAccountId() + "-" + msgId) .setShortLabel(docName.isEmpty() ? xdcName : docName) - .setIcon(IconCompat.createWithAdaptiveBitmap(bitmap)) + .setIcon(IconCompat.createWithBitmap(bitmap)) // createWithAdaptiveBitmap() removes decorations but cuts out a too small circle and defamiliarize the icon too much .setIntents(getWebxdcIntentWithParentStack(context, msgId)) .build();