OfflineIMAP / offlineimap

Read/sync your IMAP mailboxes (python2) [LEGACY: move to offlineimap3]
http://www.offlineimap.org
Other
1.78k stars 361 forks source link

Keywords: allow users to configure the separator #420

Open knghtbrd opened 7 years ago

knghtbrd commented 7 years ago

Using Debian unstable/sid with OfflineIMAP 7.0.12+dfsg1-1, I find the following config snippet separates keywords by spaces:

[Account Gmail]                                                                            
localrepository = GmailLocal                                                               
remoterepository = GmailRemote                                                             
synclabels = yes                                                                           
labelsheader = Keywords                                                                  

This does work as documented, however this is in violation of RFC 2822 section 3.6.5. Informational fields which states:

3.6.5. Informational fields

The informational fields are all optional. The "Keywords:" field contains a comma-separated list of one or more words or quoted-strings. The "Subject:" and "Comments:" fields are unstructured fields as defined in section 2.2.1, and therefore may contain text or folding white space.

subject = "Subject:" unstructured CRLF

comments = "Comments:" unstructured CRLF

keywords = "Keywords:" phrase *("," phrase) CRLF

In fact, the NeoMutt Guide suggests that it is the default X-Keywords and not the RFC-standard header that should be space-delimited:

  1. Keyword Management

Mutt has supported textual labels (usually known as X-Labels after the header that we use to store them) for many years. Since we initially added support for X-Labels, however, the larger community has evolved more common ways of using and managing such labels, often known as “ keywords”or “ tags”.

If you are new to Mutt or to using keywords in Mutt, you only need to know that the binding ( yby default) will edit keywords, and that you can search for keywords using the ~ypattern, and use the %yexpando to display it in your $index_format. You also can sort by keyword. Keywords that you set will be stored to the X-Label:header by default.

If you've been using X-Labels for a while, things have grown slightly. Mutt still supports X-Labels much as it has since 2000, but the scope of this support has expanded to support three additional header-based techniques for storing keyword metadata on messages:

X-Keywords Informal design; space-delimited keywords

X-Mozilla-Keys Informal design used by Mozilla-based agents; space-delimited keywords

Keywords Standardized in RFC2822 (2001); comma-space-delimited keywords

X-Label Mutt-specific design; freeform text (but see $xlabel_delimiter)

NeoMutt can be configured to use comma-separated X-Label with $xlabel_delimiter set accordingly, however OfflineIMAP will not write this header with commas either. It's worth noting that this feature has not migrated to mainstream Mutt, probably due to inconsistencies like this. :)

nicolas33 commented 7 years ago

I find the following config snippet separates keywords by spaces

I guess you're right. We should likely change the option so that "Keywords" use the coma as separator.

nicolas33 commented 7 years ago

@aroig is the author of this feature.

knghtbrd commented 7 years ago

It's an easy change, there's a constant at the top of imaputil.py:

# Message headers that use space as the separator (for label storage)                  
SPACE_SEPARATED_LABEL_HEADERS = ('X-Label', 'Keywords')                                

What's not easy probably is just changing it. If you're using these headers, migration from current behavior to correct behavior is an issue. When OfflineIMAP is updated, NeoMutt should be able to convert messages to the correct format (perhaps by saving all messages to a different folder and writing them back, which will be significant network traffic to sync, but it'd work.)

nicolas33 commented 7 years ago

What's not easy probably is just changing it. If you're using these headers, migration from current behavior to correct behavior is an issue.

Yes. I'm fine to apply the change and target v7.1.0 for the next release because of this.

When OfflineIMAP is updated, NeoMutt should be able to convert messages to the correct format (perhaps by saving all messages to a different folder and writing them back, which will be significant network traffic to sync, but it'd work.)

I don't know how users will handle this. IMHO, a blog post providing a HOWTO or tips about the migration should be enough. I might be wrong but I don't think most of the users use this feature.

Feel free to send a patch and a write a little blog post. I'd welcome this contribution. ,-)

http://www.offlineimap.org/doc/website-quick-start.html

aroig commented 7 years ago

At the time I wrote this feature, I looked at a couple of mail user agents (mu4e and mutt) and stuck with a choice that made them all happy. This is an old message I just found, for instance.

I'm ok in making Keywords comply with standards, although it will cause pain.

I'm dubious of what to do with the free form fields, since there will be people out there using either separator. Maybe we could make it configurable? If we do that, there would be the confusion of why Keywords only does commas. Maybe we could let Keywords to also have configurable separator, and print a warning saying that spaces violate RFC, in case the user choses that.

What do you think?

knghtbrd commented 7 years ago

Keywords should do commas only because the RFC says it does commas. That said, making the header and separator both configurable is reasonable. I think it's somewhat odd that NeoMutt only makes it so for X-Label. Probably because in the case of X-Label, it sort of has to.

On Mon, Dec 5, 2016 at 12:04 PM, Abdó Roig-Maranges < notifications@github.com> wrote:

At the time I wrote this feature, I looked at a couple of mail user agents (mu4e and mutt) and stuck with a choice that made them all happy. This http://does-not-exist.org/mail-archives/mutt-dev/msg08249.html is an old message I just found, for instance.

I'm ok in making Keywords comply with standards, although it will cause pain.

I'm dubious of what to do with the free form fields, since there will be people out there using either separator. Maybe we could make it configurable? If we do that, there would be the confusion of why Keywords only does commas. Maybe we could let Keywords to also have configurable separator, and print a warning saying that spaces violate RFC, in case the user choses that.

What do you think?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/OfflineIMAP/offlineimap/issues/420#issuecomment-264961307, or mute the thread https://github.com/notifications/unsubscribe-auth/AKR_jUiJt9sBNwPgidhKnsF_YEdJG1Jdks5rFG47gaJpZM4LDptp .

nicolas33 commented 7 years ago

Keywords should do commas only because the RFC says it does commas.

I'd say Offlineimap should rather provide legacy compatibility where applicable and hurt the users as less as possible.

That said, making the header and separator both configurable is reasonable. I think it's somewhat odd that NeoMutt only makes it so for X-Label. Probably because in the case of X-Label, it sort of has to.

I agree that allowing the users to configure the separator character is a good have in this case. ,-)