Skip to content
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

Allow use of a non-HTTPS localhost OBA server #1123

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
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 @@ -619,14 +619,24 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
* @return true if the provided apiUrl could be a valid URL, false if it could not
*/
private boolean validateUrl(String apiUrl) {
if (!apiUrl.startsWith("http")) {
// Assume HTTPS scheme if none is provided
apiUrl = getString(R.string.https_prefix) + apiUrl;
}

URL url = null;
try {
// URI.parse() doesn't tell us if the scheme is missing, so use URL() instead (#126)
URL url = new URL(apiUrl);
url = new URL(apiUrl);
} catch (MalformedURLException e) {
// Assume HTTPS scheme if none is provided
apiUrl = getString(R.string.https_prefix) + apiUrl;
return false;
}

if (url.getHost().equals("localhost")) {
return true;
} else {
return Patterns.WEB_URL.matcher(apiUrl).matches();
}
return Patterns.WEB_URL.matcher(apiUrl).matches();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<!-- See https://github.com/OneBusAway/onebusaway-multiregion-support/issues/14 for TODO list
of regions still working to transition to HTTPS. Exceptions for these regions are below. -->
<domain-config cleartextTrafficPermitted="true">
<!-- San Diego OTP server -->
<domain includeSubdomains="true">realtime.sdmts.com</domain>
<domain includeSubdomains="true">localhost</domain>
</domain-config>
</network-security-config>
Loading