Merge pull request #11 from luchua-bc/Improper_URL_verification

Address the issue related to URL validation
This commit is contained in:
Max 2020-03-23 23:12:38 +01:00 committed by GitHub
commit e3868a45cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -18,7 +18,7 @@ If you want to create an app that displays the content of a remote website
2. open the `MyWebViewClient.java` file and replace `example.com` on line **14** with your custom hostname 2. open the `MyWebViewClient.java` file and replace `example.com` on line **14** with your custom hostname
```java ```java
if (Objects.requireNonNull(Uri.parse(url).getHost()).endsWith("example.com")) { if (Objects.requireNonNull(Uri.parse(url).getHost()).endsWith(".example.com")) {
``` ```
### Using a local source ### Using a local source

View File

@ -11,7 +11,7 @@ class MyWebViewClient extends WebViewClient {
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
Uri uri = Uri.parse(url); Uri uri = Uri.parse(url);
if (uri.getHost() != null && uri.getHost().contains("example.com")) { if (uri.getHost() != null && uri.getHost().endsWith(".example.com")) {
return false; return false;
} }