[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-android] branch master updated: [wallet] Fix HTTP URIs and
From: |
gnunet |
Subject: |
[taler-taler-android] branch master updated: [wallet] Fix HTTP URIs and error handling |
Date: |
Tue, 02 Jan 2024 14:46:38 +0100 |
This is an automated email from the git hooks/post-receive script.
torsten-grote pushed a commit to branch master
in repository taler-android.
The following commit(s) were added to refs/heads/master by this push:
new 4d23c92 [wallet] Fix HTTP URIs and error handling
4d23c92 is described below
commit 4d23c920fdc1a3eb0869f32a2faff4debbc653a4
Author: Torsten Grote <t@grobox.de>
AuthorDate: Tue Jan 2 10:46:30 2024 -0300
[wallet] Fix HTTP URIs and error handling
Previously, we would crash for certain URIs. Cleartext comms only allowed
for localhost.
---
wallet/src/main/AndroidManifest.xml | 1 +
wallet/src/main/java/net/taler/wallet/MainActivity.kt | 18 ++++++++++++------
wallet/src/main/res/values/strings.xml | 1 +
wallet/src/main/res/xml/network_security_config.xml | 6 ++++++
4 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/wallet/src/main/AndroidManifest.xml
b/wallet/src/main/AndroidManifest.xml
index 7f8eb52..b8c05c6 100644
--- a/wallet/src/main/AndroidManifest.xml
+++ b/wallet/src/main/AndroidManifest.xml
@@ -40,6 +40,7 @@
android:fullBackupContent="@xml/backup_descriptor"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
+ android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
diff --git a/wallet/src/main/java/net/taler/wallet/MainActivity.kt
b/wallet/src/main/java/net/taler/wallet/MainActivity.kt
index 4cbd738..16f0efa 100644
--- a/wallet/src/main/java/net/taler/wallet/MainActivity.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainActivity.kt
@@ -66,10 +66,10 @@ import
net.taler.wallet.HostCardEmulatorService.Companion.MERCHANT_NFC_DISCONNEC
import
net.taler.wallet.HostCardEmulatorService.Companion.TRIGGER_PAYMENT_ACTION
import net.taler.wallet.databinding.ActivityMainBinding
import net.taler.wallet.refund.RefundStatus
+import java.io.IOException
import java.net.HttpURLConnection
import java.net.URL
import java.util.Locale.ROOT
-import javax.net.ssl.HttpsURLConnection
class MainActivity : AppCompatActivity(), OnNavigationItemSelectedListener,
OnPreferenceStartFragmentCallback {
@@ -186,13 +186,18 @@ class MainActivity : AppCompatActivity(),
OnNavigationItemSelectedListener,
if (scheme == "http" || scheme == "https") {
model.viewModelScope.launch(Dispatchers.IO) {
- val conn: HttpsURLConnection =
- URL(uri.toString()).openConnection() as HttpsURLConnection
+ val conn = URL(uri.toString()).openConnection() as
HttpURLConnection
Log.v(TAG, "prepare query: $uri")
conn.setRequestProperty("Accept", "text/html")
conn.connectTimeout = 5000
conn.requestMethod = "HEAD"
- conn.connect()
+ try {
+ conn.connect()
+ } catch (e: IOException) {
+ Log.e(TAG, "Error connecting to $uri ", e)
+ showError(R.string.error_broken_uri, "$uri")
+ return@launch
+ }
val status = conn.responseCode
if (status == HttpURLConnection.HTTP_OK || status ==
HttpURLConnection.HTTP_PAYMENT_REQUIRED) {
@@ -202,8 +207,7 @@ class MainActivity : AppCompatActivity(),
OnNavigationItemSelectedListener,
val talerHeaderUri = Uri.parse(talerHeader[0])
getTalerAction(talerHeaderUri, 0, actionFound)
}
- }
- if (status == HttpURLConnection.HTTP_MOVED_TEMP
+ } else if (status == HttpURLConnection.HTTP_MOVED_TEMP
|| status == HttpURLConnection.HTTP_MOVED_PERM
|| status == HttpURLConnection.HTTP_SEE_OTHER
) {
@@ -213,6 +217,8 @@ class MainActivity : AppCompatActivity(),
OnNavigationItemSelectedListener,
val locUri = Uri.parse(location[0])
getTalerAction(locUri, maxRedirects - 1, actionFound)
}
+ } else {
+ showError(R.string.error_broken_uri, "$uri")
}
}
} else {
diff --git a/wallet/src/main/res/values/strings.xml
b/wallet/src/main/res/values/strings.xml
index 09feee6..058c30b 100644
--- a/wallet/src/main/res/values/strings.xml
+++ b/wallet/src/main/res/values/strings.xml
@@ -65,6 +65,7 @@ GNU Taler is immune against many types of fraud, such as
phishing of credit card
<string name="offline">Operation requires internet access. Please ensure
your internet connection works and try again.</string>
<string name="offline_banner">No internet access</string>
<string name="error_unsupported_uri">Error: This Taler URI is not
supported.</string>
+ <string name="error_broken_uri">Error: This Taler URI is (currently) not
working.</string>
<string name="menu_settings">Settings</string>
<string name="menu_retry_pending_operations">Retry Pending
Operations</string>
diff --git a/wallet/src/main/res/xml/network_security_config.xml
b/wallet/src/main/res/xml/network_security_config.xml
new file mode 100644
index 0000000..de61259
--- /dev/null
+++ b/wallet/src/main/res/xml/network_security_config.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<network-security-config>
+ <domain-config cleartextTrafficPermitted="true">
+ <domain includeSubdomains="true">localhost</domain>
+ </domain-config>
+</network-security-config>
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-taler-android] branch master updated: [wallet] Fix HTTP URIs and error handling,
gnunet <=