mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-03 18:26:20 +00:00
Trim names
This commit is contained in:
parent
4d67d89528
commit
197762b9a3
2 changed files with 18 additions and 0 deletions
|
@ -170,6 +170,9 @@ public class EntityAnswer implements Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
first = Helper.trim(first, ".");
|
||||
last = Helper.trim(last, ".");
|
||||
|
||||
text = text.replace("$name$", fullName == null ? "" : Html.escapeHtml(fullName));
|
||||
text = text.replace("$firstname$", first == null ? "" : Html.escapeHtml(first));
|
||||
text = text.replace("$lastname$", last == null ? "" : Html.escapeHtml(last));
|
||||
|
|
|
@ -2151,6 +2151,21 @@ public class Helper {
|
|||
return (c == '.' /* Latin */ || c == '。' /* Chinese */);
|
||||
}
|
||||
|
||||
static String trim(String value, String chars) {
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
for (Character kar : chars.toCharArray()) {
|
||||
String k = kar.toString();
|
||||
while (value.startsWith(k))
|
||||
value = value.substring(1);
|
||||
while (value.endsWith(k))
|
||||
value = value.substring(0, value.length() - 1);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// Files
|
||||
|
||||
static {
|
||||
|
|
Loading…
Reference in a new issue