Re: Unknown character encoding when sorting mailboxes in Horde

2016-02-23 Thread Arnt Gulbrandsen

OVi C writes:

Here's is the answer from the horde developers regarding the issue:

...

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.  "


This erratum has been updated, aox is right, horde is wrong.

Arnt



Re: Unknown character encoding when sorting mailboxes in Horde

2016-01-27 Thread Arnt Gulbrandsen

OVi C writes:

Hi again.
I've applied the patch and it's working. Thank you very much.


I'll commit it then. Thanks.

Bit harsh to call this behavious broken; the code as it was complied with 
all four relevant published RFCs. I'll raise the issue in the IETF. That 
erratum has to be amended.


Arnt



Re: Unknown character encoding when sorting mailboxes in Horde

2016-01-26 Thread Arnt Gulbrandsen

I wrote:

There are two bugs, AFAICT.


No. Horde is right. Will fix.

Arnt



Re: Unknown character encoding when sorting mailboxes in Horde

2016-01-26 Thread Arnt Gulbrandsen

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() ) {


Re: Unknown character encoding when sorting mailboxes in Horde

2015-12-01 Thread Arnt Gulbrandsen

OVi C writes:
I have a lot of messages in INBOX that doesn't show after 
changing sort order (by date, by size, etc) and getting and 
error on the horde interface .


Looks like a syntax error in Horde.


I've attached the imap log between horde aplication and the imap server.

C: 5 UID SORT (SUBJECT) ALL


According to the specification that misses one argument, and should be

C: 5 UID SORT (SUBJECT) UTF-8 ALL

or some other charset; aox  tries to interpret "all" as the name of a 
charset and that fails. I wonder if I should perhaps make the charset name 
optional...


Arnt