mirror of https://github.com/M66B/FairEmail.git
Revert "Better search bug workaround"
This reverts commit ca97512a3a
.
There is no use in sending UTF-8 searches if the server doesn't support UTF-8
This commit is contained in:
parent
ca97512a3a
commit
622b40209d
|
@ -174,7 +174,6 @@ public class ViewModelBrowse extends ViewModel {
|
||||||
@Override
|
@Override
|
||||||
public Object doCommand(IMAPProtocol protocol) {
|
public Object doCommand(IMAPProtocol protocol) {
|
||||||
try {
|
try {
|
||||||
boolean keywords = (folder.keywords.length > 0);
|
|
||||||
if (protocol.supportsUtf8()) {
|
if (protocol.supportsUtf8()) {
|
||||||
// SEARCH OR OR FROM "x" TO "x" OR SUBJECT "x" BODY "x" ALL
|
// SEARCH OR OR FROM "x" TO "x" OR SUBJECT "x" BODY "x" ALL
|
||||||
// SEARCH OR OR OR FROM "x" TO "x" OR SUBJECT "x" BODY "x" (KEYWORD x) ALL
|
// SEARCH OR OR OR FROM "x" TO "x" OR SUBJECT "x" BODY "x" (KEYWORD x) ALL
|
||||||
|
@ -194,7 +193,7 @@ public class ViewModelBrowse extends ViewModel {
|
||||||
arg.writeBytes(state.search.getBytes());
|
arg.writeBytes(state.search.getBytes());
|
||||||
arg.writeAtom("BODY");
|
arg.writeAtom("BODY");
|
||||||
arg.writeBytes(state.search.getBytes());
|
arg.writeBytes(state.search.getBytes());
|
||||||
if (keywords) {
|
if (folder.keywords.length > 0) {
|
||||||
arg.writeAtom("KEYWORD");
|
arg.writeAtom("KEYWORD");
|
||||||
arg.writeBytes(state.search.getBytes());
|
arg.writeBytes(state.search.getBytes());
|
||||||
}
|
}
|
||||||
|
@ -225,30 +224,10 @@ public class ViewModelBrowse extends ViewModel {
|
||||||
return imessages;
|
return imessages;
|
||||||
} else {
|
} else {
|
||||||
// No UTF-8 support
|
// No UTF-8 support
|
||||||
try {
|
|
||||||
Log.i("Boundary default search=" + state.search);
|
|
||||||
return state.ifolder.search(getSearchTerm(state.search, keywords));
|
|
||||||
} catch (MessagingException ex) {
|
|
||||||
Log.w(ex);
|
|
||||||
|
|
||||||
// Workaround:
|
|
||||||
// javax.mail.MessagingException: AE5 BAD Error in IMAP command SEARCH: 8bit data in atom;
|
|
||||||
// nested exception is:
|
|
||||||
// com.sun.mail.iap.BadCommandException: AE5 BAD Error in IMAP command SEARCH: 8bit data in atom
|
|
||||||
String search = Normalizer
|
String search = Normalizer
|
||||||
.normalize(state.search, Normalizer.Form.NFD)
|
.normalize(state.search, Normalizer.Form.NFD)
|
||||||
.replaceAll("[^\\p{ASCII}]", "");
|
.replaceAll("[^\\p{ASCII}]", "");
|
||||||
Log.i("Boundary ASCII search=" + search);
|
Log.i("Boundary ASCII search=" + search);
|
||||||
return state.ifolder.search(getSearchTerm(search, keywords));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (MessagingException ex) {
|
|
||||||
Log.e(ex);
|
|
||||||
return ex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private SearchTerm getSearchTerm(String search, boolean keywords) {
|
|
||||||
SearchTerm term = new OrTerm(
|
SearchTerm term = new OrTerm(
|
||||||
new OrTerm(
|
new OrTerm(
|
||||||
new FromStringTerm(search),
|
new FromStringTerm(search),
|
||||||
|
@ -259,10 +238,17 @@ public class ViewModelBrowse extends ViewModel {
|
||||||
new BodyTerm(search)
|
new BodyTerm(search)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if (keywords)
|
|
||||||
term = new OrTerm(term,
|
if (folder.keywords.length > 0)
|
||||||
new FlagTerm(new Flags(Helper.sanitizeKeyword(search)), true));
|
term = new OrTerm(term, new FlagTerm(
|
||||||
return term;
|
new Flags(Helper.sanitizeKeyword(search)), true));
|
||||||
|
|
||||||
|
return state.ifolder.search(term);
|
||||||
|
}
|
||||||
|
} catch (MessagingException ex) {
|
||||||
|
Log.e(ex);
|
||||||
|
return ex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue