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