Patch for testing attached.
OVi C writes:
Here's is the answer from the horde developers regarding the issue:
"From RFC 6855:
Once an IMAP client has enabled UTF-8 support with the "ENABLE
UTF8=ACCEPT" command, it MUST NOT issue a "SEARCH" command that
contains a charset specification. If an IMAP server receives such a
"SEARCH" command in that situation, it SHOULD reject the command with
a "BAD" response (due to the conflicting charset labels).
I remember protesting against that last sentence when I reviewed the RFC
before it was published. In aox' case the charset labels do not conflict,
and therefore aox sees no proper reason to issue BAD. But see below.
Bottom line: your IMAP server is broken.
Oh, and since we're using SORT and not SEARCH, from the RFC's errata:
This also
applies to any IMAP command or extension that includes a charset
label and associated strings in the command arguments. Such
extensions presently include SORT, THREAD and MULTISEARCH. "
Uh-huh. I've read the erratum now and think it's incorrect. It says, among
other things, that the existing syntax is incorrect, but it doesn't specify
new syntax. ( can guess what it intends, but that's not good enough for an
RFC.
Please test the attached patch; it implements optional charset syntax for
both sort and thread. It's probably a little more flexible and optional
than the erratum intends.
Arnt
diff --git a/imap/handlers/sort.cpp b/imap/handlers/sort.cpp
index ed334d9..40cc024 100644
--- a/imap/handlers/sort.cpp
+++ b/imap/handlers/sort.cpp
@@ -4,6 +4,7 @@
#include "user.h"
#include "field.h"
+#include "codec.h"
#include "mailbox.h"
#include "imapparser.h"
#include "imapsession.h"
@@ -149,9 +150,18 @@ void Sort::parse()
space();
+// Optional charset; there is an erratum in 6855 that doesn't
+// specify syntax. I bet this isn't quite what Barry had in mind.
+parser()->mark();
+EString charset = astring();
+if ( Codec::byName( charset ) ) {
+setCharset( charset );
+space();
+} else {
+parser()->restore();
+}
+
// search-criteria
-setCharset( astring() );
-space();
d->s = new Selector;
d->s->add( parseKey() );
while ( ok() && !parser()->atEnd() ) {
diff --git a/imap/handlers/thread.cpp b/imap/handlers/thread.cpp
index 4d6650b..6c50c02 100644
--- a/imap/handlers/thread.cpp
+++ b/imap/handlers/thread.cpp
@@ -6,6 +6,7 @@
#include "imapparser.h"
#include "message.h"
#include "address.h"
+#include "codec.h"
#include "field.h"
#include "query.h"
#include "dict.h"
@@ -109,8 +110,11 @@ void Thread::parse()
else
error( Bad, "Unsupported thread algorithm" );
space();
-astring(); // charset, roundly ignored
-space();
+parser()->mark();
+if ( Codec::byName( astring() ) )
+space();
+else
+parser()->restore();
d->s = new Selector;
d->s->add( parseKey() );
while ( ok() && !parser()->atEnd() ) {