mirror of https://github.com/M66B/FairEmail.git
Allow uppercase http
This commit is contained in:
parent
10eef9506a
commit
7c20e2ee97
|
@ -606,7 +606,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
ImageSpan[] image = buffer.getSpans(off, off, ImageSpan.class);
|
||||
if (image.length > 0 && image[0].getSource() != null) {
|
||||
Uri uri = Uri.parse(image[0].getSource());
|
||||
if ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme())) {
|
||||
if (UriHelper.isHyperLink(uri)) {
|
||||
ripple(event);
|
||||
if (onOpenLink(uri, null, false))
|
||||
return true;
|
||||
|
@ -5855,7 +5855,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
String host = guri.getHost();
|
||||
|
||||
boolean confirm_link =
|
||||
!"https".equals(scheme) || TextUtils.isEmpty(host) ||
|
||||
!"https".equalsIgnoreCase(scheme) || TextUtils.isEmpty(host) ||
|
||||
prefs.getBoolean(host + ".confirm_link", true);
|
||||
if (always_confirm || (confirm_links && confirm_link)) {
|
||||
Bundle args = new Bundle();
|
||||
|
@ -5914,7 +5914,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
}
|
||||
}.execute(context, owner, args, "view:cid");
|
||||
|
||||
else if ("http".equals(scheme) || "https".equals(scheme))
|
||||
else if ("http".equalsIgnoreCase(scheme) || "https".equalsIgnoreCase(scheme))
|
||||
onOpenLink(uri, null, false);
|
||||
|
||||
else if ("data".equals(scheme))
|
||||
|
|
|
@ -499,7 +499,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
|
|||
|
||||
cbNotAgain.setText(context.getString(R.string.title_no_ask_for_again, uri.getHost()));
|
||||
cbNotAgain.setVisibility(
|
||||
"https".equals(uri.getScheme()) && !TextUtils.isEmpty(uri.getHost())
|
||||
UriHelper.isSecure(uri) && !TextUtils.isEmpty(uri.getHost())
|
||||
? View.VISIBLE : View.GONE);
|
||||
|
||||
setMore(false);
|
||||
|
@ -520,7 +520,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
|
|||
PackageManager pm = context.getPackageManager();
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW)
|
||||
.addCategory(Intent.CATEGORY_BROWSABLE)
|
||||
.setData(uri);
|
||||
.setData(UriHelper.fix(uri));
|
||||
|
||||
ResolveInfo main = pm.resolveActivity(intent, 0);
|
||||
if (main != null) {
|
||||
|
@ -659,7 +659,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
|
|||
// https://developer.android.com/training/basics/intents/sending#AppChooser
|
||||
Uri uri = Uri.parse(etLink.getText().toString());
|
||||
Log.i("Open link with uri=" + uri);
|
||||
Intent view = new Intent(Intent.ACTION_VIEW, uri);
|
||||
Intent view = new Intent(Intent.ACTION_VIEW, UriHelper.fix(uri));
|
||||
Intent chooser = Intent.createChooser(view, context.getString(R.string.title_select_app));
|
||||
try {
|
||||
startActivity(chooser);
|
||||
|
@ -719,7 +719,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
|
|||
if (scheme != null) {
|
||||
int index = text.indexOf(scheme);
|
||||
if (index >= 0)
|
||||
if ("http".equals(scheme)) {
|
||||
if ("http".equalsIgnoreCase(scheme)) {
|
||||
ssb.setSpan(new ForegroundColorSpan(colorWarning),
|
||||
index, index + scheme.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
ssb.setSpan(new StyleSpan(Typeface.BOLD),
|
||||
|
|
|
@ -888,7 +888,7 @@ public class Helper {
|
|||
|
||||
static void view(Context context, Intent intent) {
|
||||
Uri uri = intent.getData();
|
||||
if ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme()))
|
||||
if (UriHelper.isHyperLink(uri))
|
||||
view(context, intent.getData(), false);
|
||||
else
|
||||
try {
|
||||
|
@ -924,7 +924,9 @@ public class Helper {
|
|||
" isInstalled=" + isInstalled(context, open_with_pkg) +
|
||||
" hasCustomTabs=" + hasCustomTabs(context, uri, open_with_pkg));
|
||||
|
||||
if (!UriHelper.isHyperLink(uri)) {
|
||||
if (UriHelper.isHyperLink(uri))
|
||||
uri = UriHelper.fix(uri);
|
||||
else {
|
||||
open_with_pkg = null;
|
||||
open_with_tabs = false;
|
||||
}
|
||||
|
|
|
@ -338,7 +338,7 @@ public class UriHelper {
|
|||
} else
|
||||
url = uri;
|
||||
|
||||
if (url.isOpaque() || !UriHelper.isHyperLink(url))
|
||||
if (url.isOpaque() || !isHyperLink(url))
|
||||
return uri;
|
||||
|
||||
Uri.Builder builder = url.buildUpon();
|
||||
|
@ -402,12 +402,24 @@ public class UriHelper {
|
|||
}
|
||||
|
||||
static boolean isSecure(Uri uri) {
|
||||
return (!uri.isOpaque() && "https".equals(uri.getScheme()));
|
||||
return (!uri.isOpaque() && "https".equalsIgnoreCase(uri.getScheme()));
|
||||
}
|
||||
|
||||
static boolean isHyperLink(Uri uri) {
|
||||
return (!uri.isOpaque() &&
|
||||
("http".equals(uri.getScheme()) || "https".equals(uri.getScheme())));
|
||||
("http".equalsIgnoreCase(uri.getScheme()) ||
|
||||
"https".equalsIgnoreCase(uri.getScheme())));
|
||||
}
|
||||
|
||||
static Uri fix(Uri uri) {
|
||||
if ("HTTP".equals(uri.getScheme()) || "HTTPS".equals(uri.getScheme())) {
|
||||
String u = uri.toString();
|
||||
int semi = u.indexOf(':');
|
||||
if (semi > 0)
|
||||
return Uri.parse(u.substring(0, semi).toLowerCase(Locale.ROOT) + u.substring(semi));
|
||||
}
|
||||
|
||||
return uri;
|
||||
}
|
||||
|
||||
static void test(Context context) {
|
||||
|
|
Loading…
Reference in New Issue