mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-31 06:08:31 +02:00
Refactoring
This commit is contained in:
@@ -128,6 +128,32 @@ public class TextHelper {
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
int codepoint;
|
||||
Character.UnicodeScript us;
|
||||
Character.UnicodeScript script = null;
|
||||
for (int i = 0; i < s.length(); ) {
|
||||
codepoint = s.codePointAt(i);
|
||||
i += Character.charCount(codepoint);
|
||||
us = Character.UnicodeScript.of(codepoint);
|
||||
if (us.equals(Character.UnicodeScript.COMMON))
|
||||
continue;
|
||||
if (script == null)
|
||||
script = us;
|
||||
else if (!us.equals(script))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static String normalizeNotification(Context context, String text) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean notify_transliterate = prefs.getBoolean("notify_transliterate", false);
|
||||
|
||||
Reference in New Issue
Block a user