Refactoring

pull/197/head
M66B 5 years ago
parent e54a9a2ecd
commit 2fe8e58cf9

@ -498,7 +498,7 @@ public class FragmentAnswer extends FragmentBase {
args.putInt("start", etText.getSelectionStart());
args.putInt("end", etText.getSelectionEnd());
FragmentDialogLink fragment = new FragmentDialogLink();
FragmentDialogInsertLink fragment = new FragmentDialogInsertLink();
fragment.setArguments(args);
fragment.setTargetFragment(this, REQUEST_LINK);
fragment.show(getParentFragmentManager(), "answer:link");

@ -1831,7 +1831,7 @@ public class FragmentCompose extends FragmentBase {
args.putInt("start", etBody.getSelectionStart());
args.putInt("end", etBody.getSelectionEnd());
FragmentDialogLink fragment = new FragmentDialogLink();
FragmentDialogInsertLink fragment = new FragmentDialogInsertLink();
fragment.setArguments(args);
fragment.setTargetFragment(this, REQUEST_LINK);
fragment.show(getParentFragmentManager(), "compose:link");

@ -36,7 +36,7 @@ import androidx.appcompat.app.AlertDialog;
import static android.app.Activity.RESULT_OK;
public class FragmentDialogLink extends FragmentDialogBase {
public class FragmentDialogInsertLink extends FragmentDialogBase {
private EditText etLink;
@Override

@ -309,9 +309,10 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
String host = uri.getHost();
String thost = (uriTitle == null ? null : uriTitle.getHost());
String puny;
String puny = null;
try {
puny = IDN.toASCII(host);
if (host != null)
puny = IDN.toASCII(host, IDN.ALLOW_UNASSIGNED);
} catch (Throwable ex) {
Log.e(ex);
puny = host;
@ -322,7 +323,7 @@ public class FragmentDialogOpenLink extends FragmentDialogBase {
tvSuspicious.setVisibility(View.VISIBLE);
} else {
etLink.setText(uri.toString());
tvSuspicious.setVisibility(View.GONE);
tvSuspicious.setVisibility(Helper.isSingleScript(host) ? View.GONE : View.VISIBLE);
}
grpDifferent.setVisibility(

@ -1113,6 +1113,10 @@ public class Helper {
static boolean isSingleScript(String s) {
// https://en.wikipedia.org/wiki/IDN_homograph_attack
if (TextUtils.isEmpty(s))
return true;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
return true;

@ -1580,7 +1580,7 @@ public class MessageHelper {
String domain = email.substring(at + 1);
try {
user = IDN.toASCII(user);
user = IDN.toASCII(user, IDN.ALLOW_UNASSIGNED);
} catch (IllegalArgumentException ex) {
Log.e(ex);
}
@ -1588,7 +1588,7 @@ public class MessageHelper {
String[] parts = domain.split("\\.");
for (int p = 0; p < parts.length; p++)
try {
parts[p] = IDN.toASCII(parts[p]);
parts[p] = IDN.toASCII(parts[p], IDN.ALLOW_UNASSIGNED);
} catch (IllegalArgumentException ex) {
Log.e(ex);
}

Loading…
Cancel
Save