Skip to content

Commit 8b04d02

Browse files
committed
Merge branch 'allow'
2 parents 863a0f0 + 8bf4cca commit 8b04d02

File tree

1 file changed

+5
-38
lines changed
  • frontends/android/BitBoxApp/app/src/main/java/ch/shiftcrypto/bitboxapp

1 file changed

+5
-38
lines changed

frontends/android/BitBoxApp/app/src/main/java/ch/shiftcrypto/bitboxapp/MainActivity.java

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ public class MainActivity extends AppCompatActivity {
7575

7676
GoService goService;
7777

78-
private String location = "";
79-
8078
// This is for the file picker dialog invoked by file upload forms in the WebView.
8179
// Used by e.g. MoonPay's KYC forms.
8280
private ValueCallback<Uri[]> filePathCallback;
@@ -222,12 +220,6 @@ public void run() {
222220
vw.getSettings().setMediaPlaybackRequiresUserGesture(false);
223221

224222
vw.setWebViewClient(new WebViewClient() {
225-
@Override
226-
public void onPageFinished(WebView view, String url) {
227-
// The url is not correctly updated when navigating to a new page. This allows to
228-
// know the current location and to block external requests on that base.
229-
view.evaluateJavascript("window.location.pathname", path -> location = path);
230-
}
231223
@Override
232224
public WebResourceResponse shouldInterceptRequest(final WebView view, WebResourceRequest request) {
233225
if (request != null && request.getUrl() != null) {
@@ -246,30 +238,10 @@ public WebResourceResponse shouldInterceptRequest(final WebView view, WebResourc
246238
}
247239
} else {
248240
// external request
249-
// allow if location is listed
250-
List<Pattern> patterns = new ArrayList<>();
251-
patterns.add(Pattern.compile("^\"/buy/pocket/.*\"$"));
252-
patterns.add(Pattern.compile("^\"/buy/moonpay/.*\"$"));
253-
patterns.add(Pattern.compile("^\"/bitsurance/.*\"$"));
254-
patterns.add(Pattern.compile("^\"/account/[^\\/]+/wallet-connect/.*\"$"));
255-
for (Pattern pattern : patterns) {
256-
if (pattern.matcher(location).matches()) {
257-
return super.shouldInterceptRequest(view, request);
258-
}
259-
}
260-
261-
String domain = request.getUrl().getHost();
262-
if (domain != null) {
263-
// allow if domain is listed
264-
patterns = new ArrayList<>();
265-
patterns.add(Pattern.compile("^verify\\.walletconnect\\.com$"));
266-
for (Pattern pattern : patterns) {
267-
if (pattern.matcher(domain).matches()) {
268-
return super.shouldInterceptRequest(view, request);
269-
}
270-
}
271-
}
272-
Util.log("Blocked: " + url);
241+
// Unlike the Qt app, we don't allow requests based on which URL we are in
242+
// currently within the React app, as it's very hard to figure what the
243+
// current app URL is without having the frontend itself inform us.
244+
return super.shouldInterceptRequest(view, request);
273245
}
274246
} else {
275247
Util.log("Null request!");
@@ -365,12 +337,7 @@ public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathC
365337
final String javascriptVariableName = "android";
366338
vw.addJavascriptInterface(new JavascriptBridge(this), javascriptVariableName);
367339

368-
try {
369-
String data = readRawText(getAssets().open("web/index.html"));
370-
vw.loadDataWithBaseURL(BASE_URL, data, null, null, null);
371-
} catch (IOException e) {
372-
e.printStackTrace();
373-
}
340+
vw.loadUrl(BASE_URL + "index.html");
374341

375342
// We call updateDevice() here in case the app was started while the device was already connected.
376343
// In that case, handleIntent() is not called with ACTION_USB_DEVICE_ATTACHED.

0 commit comments

Comments
 (0)