Skip to content

Add configuration option of disallowing subdomains #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public interface Listener {
protected WeakReference<Activity> mActivity;
protected WeakReference<Fragment> mFragment;
protected Listener mListener;
protected boolean mAllowSubdomains = true;
protected final List<String> mPermittedHostnames = new LinkedList<String>();
/** File upload callback for platform versions prior to Android 5.0 */
protected ValueCallback<Uri> mFileUploadCallbackFirst;
Expand Down Expand Up @@ -340,6 +341,14 @@ public void addHttpHeader(final String name, final String value) {
public void removeHttpHeader(final String name) {
mHttpHeaders.remove(name);
}

public void setAllowSubdomains(boolean b){
mAllowSubdomains = b;
}

public boolean getAllowSubdomains(){
return mAllowSubdomains;
}

public void addPermittedHostname(String hostname) {
mPermittedHostnames.add(hostname);
Expand Down Expand Up @@ -503,7 +512,7 @@ public void onReceivedError(WebView view, int errorCode, String description, Str

@Override
public boolean shouldOverrideUrlLoading(final WebView view, final String url) {
if (!isPermittedUrl(url)) {
if (!isPermittedUrl(url, mAllowSubdomains)) {
// if a listener is available
if (mListener != null) {
// inform the listener about the request
Expand Down