Charalampos Nikolaou <char.nikol...@gmail.com> added the comment:

Hi, actually I must have found the real culprit. And this is that imaplib does 
not include a function for the "EXAMINE" command. What it does is that when a 
user selects a mailbox as readonly, it executes an EXAMINE command instead of a 
SELEECT command, which is wrong according to RFC2060 
(http://james.apache.org/server/rfclist/imap4/rfc2060.txt) that explicitly 
states the following:

"Read-only access through SELECT differs from the EXAMINE command in that 
certain read-only mailboxes MAY permit the change of permanent state on a 
per-user (as opposed to global) basis.  Netnews messages marked in  a 
server-based .newsrc file are an example of such per-user permanent state that 
can be modified with read-only mailboxes."

As a consequence of the above text, if a mailbox has been selected with the 
EXAMINE command, fetching a mail does not make the mail as read, which would be 
done if the mailbox had been selected with the SELECT command even in the case 
the mailbox had read-only permissions.

A quick patch for imaplib is to have it not raising any exceptions when 
checking the READ-ONLY state. In this way, one can open a read-only mailbox 
using the SELECT command as follows:

imap.select(mailbox)

Preventing imaplib from raising exceptions when using the above command with 
read-only mailboxes, it allows someone to fetch a message and then marked it as 
seen. After all, the exceptions are of no use, because the IMAP server is 
responsible for making security checks and not the client.

To have imaplib be compliant with RFC2060, I propose including an examine 
function which would be like select. Pure and simply.

I attach a patch for imaplib 2.58 (Python 2.6.2) which "solves" this 
misbehavior by not raising exceptions for READ-ONLY mailboxes when having 
opened them without "readonly=True". 

What are your opinions on this?

----------
keywords: +patch
Added file: http://bugs.python.org/file23762/imaplib.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13446>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to