1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-26 17:57:16 +00:00

Search UTF-8

This commit is contained in:
M66B 2023-03-13 16:33:13 +01:00
parent 1c3e2170fc
commit 60bbea131a

View file

@ -718,7 +718,14 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
Argument args = ss.generateSequence(terms, utf8 ? StandardCharsets.UTF_8.name() : null);
args.writeAtom("ALL");
Response[] responses = protocol.command("SEARCH", args); // no CHARSET !
// https://www.rfc-editor.org/rfc/rfc3501#section-6.4.4
Response[] responses = protocol.command("SEARCH" + (utf8 ? " CHARSET UTF-8" : ""), args);
if (responses != null && responses.length > 0 && !responses[responses.length - 1].isOK()) {
// Normally "NO"
if (!BuildConfig.PLAY_STORE_RELEASE)
Log.e(responses[responses.length - 1].toString());
responses = protocol.command("SEARCH", args);
}
if (responses == null || responses.length == 0)
throw new ProtocolException("No response from server");
for (Response response : responses)
@ -1045,6 +1052,11 @@ public class BoundaryCallbackMessages extends PagedList.BoundaryCallback<TupleMe
search = Normalizer
.normalize(search, Normalizer.Form.NFKD)
.replaceAll("[^\\p{ASCII}]", "");
if (TextUtils.isEmpty(search)) {
String msg = "Cannot convert to ASCII: " + query;
Log.e(msg);
throw new IllegalArgumentException(msg);
}
}
List<String> word = new ArrayList<>();