Commit Graph

2787 Commits

Author SHA1 Message Date
Adam Dinwoodie
416df5d7c2 Skip parsing date after failing to parse the date
When file_use_mail_timestamp or utime_from_header are enabled,
OfflineIMAP tries to parse the Date header in the email.  If the header
is present but invalid -- it doesn't contain a valid date -- this will
cause email.message to raise an exception.  This is all fine.  However
when handling that exception, OfflineIMAP can't try to extract the date
again: it's clearly invalid, and raising the same exception a second
time while handling the first exception just causes the entire sync to
fail.

To avoid that happening, don't try to provide the invalid date string in
the error message.  Instead, just give the user the UID of the email
that triggered the exception, and the exception text.

Ideally we'd instead fix the code to actually extract the header value
and provide it in the error message, but Python's email.message module
doesn't provide an easy way to get the raw text of the Date header from
an EmailMessage object; it's possible using private variables like
EmailMessage._headers, or by parsing the email using a custom
email.policy.EmailPolicy object that disables the module's attempts to
coerce the header value to a DateTime.  However, a user should be able
to get the problematic Date header from the message directly anyway, so
it's not worth adding all that complexity for something that should be
rare and provides little value.

Fixes #134

Signed-off-by: Adam Dinwoodie <adam@dinwoodie.org>
2022-08-25 16:26:57 +01:00
Rodolfo García Peñas (kix)
253f97a3e9
Merge pull request #86 from dopefishh/communicate-syncmode-to-synchooks
Communicate syncmode to synchooks
2022-03-25 11:43:10 +01:00
Rodolfo García Peñas (kix)
b5001c2ae7
Merge pull request #98 from nicolas33/706-int-not-subscriptable
don't fail to report error when exception args are not as expected
2022-03-25 11:42:21 +01:00
Rodolfo García Peñas (kix)
725022991a
Merge pull request #112 from alessio-pascolini/fix-nonetype-decode
Update IMAP.py
2022-03-25 11:41:21 +01:00
Rodolfo García Peñas (kix)
dd0edb1446
Merge pull request #113 from hubearth/master
Allow filtering of folders with spaces
2022-03-25 11:39:48 +01:00
Rodolfo García Peñas (kix)
6cec099e70
Merge pull request #114 from lilydjwg/master
fix imap4-utf-7 decoding errors
2022-03-25 11:36:27 +01:00
lilydjwg
90be450f4d fix imap4-utf-7 decoding errors
>>> import offlineimap.imaputil
>>> b'&g0l6Pw-'.decode('imap4-utf-7')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/ldata/src/offlineimap3/offlineimap/imaputil.py", line 406, in utf7m_decode
    for c in binary.decode():
AttributeError: 'memoryview' object has no attribute 'decode'

Signed-off-by: lilydjwg <lilydjwg@gmail.com>
2022-03-25 18:29:43 +08:00
Hubert Pineault
7b408b0c58 Allow filtering of folders with spaces
This patch adds support to filter folders with the space caracter.

When the folder includes spaces, the folder name must be quoted.
This commit is basicaly a copy-paste of commit 81bd57e4

Signed-off-by: Hubert Pineault <hpineault@riseup.net>
2022-03-22 00:46:39 -04:00
alessio-pascolini
210c23bdee
Update IMAP.py
Return before decoding items of imapdata, None cannot be decoded.
2022-03-08 10:22:11 +01:00
Nicolas Sebrecht
f418754087 don't fail to report error when exception args are not as expected
Also, quit the "elif" logic because each case is raising an exception.

Fixes #97
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2021-10-31 00:03:02 +02:00
Rodolfo García Peñas (kix)
e64c254072
Merge pull request #94 from thekix/master
v8.0.0
2021-10-18 15:03:10 +02:00
Rodolfo García Peñas (kix)
557ca854c2 v8.0.0 2021-10-18 15:00:16 +02:00
Rodolfo García Peñas (kix)
6204223383
Merge pull request #93 from thekix/master
Include offlineimap and pid in non interactive logs
2021-10-12 18:02:29 +02:00
Rodolfo García Peñas (kix)
f8cfe98d9c Include offlineimap and pid in non interactive logs
This patch includes the "offlineimap" string and the proccess id
in the output for non interactive logs and syslog logs.

Now, the output is something like this (syslog):

Oct 11 21:55:10 yangon offlineimap[635798]: Syncing foo: IMAP -> Maildir
Oct 11 21:55:10 yangon offlineimap[635798]: Syncing foo bar: IMAP -> Maildir
Oct 11 21:55:10 yangon offlineimap[635798]: Syncing INBOX: IMAP -> Maildir
Oct 11 21:55:10 yangon offlineimap[635798]: Syncing bar: IMAP -> Maildir
Oct 11 21:55:10 yangon offlineimap[635798]: Syncing Trash: IMAP -> Maildir

Closes #88
2021-10-12 18:00:51 +02:00
Rodolfo García Peñas (kix)
2ce05bc98a
Merge pull request #92 from thekix/master
Support for IMAPv4 ID extension
2021-10-12 12:04:27 +02:00
Rodolfo García Peñas (kix)
ea4b0438fe Support for IMAPv4 ID extension
This patch enables the ID extension of IMAPv4.

The patch sends the client name and the client version to the server.

Usually, the server doesn't require it, but in some cases the server
drop de connection if the ID is not send.

#Close #71
2021-10-12 11:58:47 +02:00
Rodolfo García Peñas (kix)
88e318fab1
Merge pull request #91 from thekix/master
Revert patches about ssl certificates
2021-10-12 11:21:12 +02:00
Rodolfo García Peñas (kix)
3ef991c83e Revert "Use system sslcacertfile by default"
This reverts commit a4863b2f04.
2021-10-12 10:30:09 +02:00
Rodolfo García Peñas (kix)
31149d1b1f Revert "disable verification of ssl certs via CA if fingerpint is set"
This reverts commit 871b1175f1.
2021-10-12 10:30:00 +02:00
Mart Lubbers
7748de52fb Communicate syncmode to synchooks
This patch sets the environment variable OFFLINEIMAPSYNCMODE to either
full, quick or idle depending on the context of the pre- and
postsynchook.

Adding the context as an argument was considered but this would break
existing configurations and it makes calling a program directly more
cumbersome. Some programs (e.g. imapfilter) may not know what to do with
this extra argument.

Signed-off-by: Mart Lubbers <mart@martlubbers.net>
2021-09-07 09:43:16 +02:00
Rodolfo García Peñas (kix)
4ca9c75c6f
Merge pull request #84 from benyanke/docker-image
Draft: Add Dockerfile
2021-08-25 09:11:02 +02:00
Rodolfo García Peñas (kix)
7410bc3abe
Merge pull request #83 from peeweep/patch-remotehosteval
BUG: Right format for host using remotehosteval
2021-08-25 09:10:49 +02:00
Ben Yanke
769f7ce218 start work on dockerfile
Signed-off-by: Ben Yanke <ben@benyanke.com>
2021-08-24 16:56:05 -05:00
peeweep
c21a7fa0a3 BUG: Right format for host using remotehosteval
Similarly to 7a428537, reading the host
using remotehosteval returns a bytes objects instead an utf-8 string.

This patch includes support for both string and bytes objects.
2021-08-14 07:02:45 +08:00
Rodolfo García Peñas (kix)
896ac98984
Merge pull request #81 from thekix/master
Handle connection errors
2021-08-07 21:00:12 +02:00
Rodolfo García Peñas (kix)
6a88896607 Handle socks connection errors
This patch handles the socks connection problems. First, move the "msg"
variable to the places where the variable is used. This variable could
be unset in the for loop, so is better move to these places.

This patch also removes the "msg" variable set in th except blocks, like
except socket.error as msg, because the variable is not used.

The patch also removes the "i" variable, not used.

Finally, the patch correct some typos.

Close: #67

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2021-08-07 20:57:46 +02:00
Rodolfo García Peñas (kix)
48f2df4267 Handle connection refused messages
This patch handle the connection refused messages. One of these messages
is related to returned zeros.
2021-08-07 20:33:06 +02:00
Rodolfo García Peñas (kix)
f6e9d875e8
Merge pull request #80 from thekix/master
Allow create and delete folders with spaces
2021-08-07 15:50:55 +02:00
Rodolfo García Peñas (kix)
81bd57e434 Allow create and delete folders with spaces
This patch adds support to create and delete folders with the space
character.

When the folder includes spaces, all the folder name must be quoted.

Close: #58

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2021-08-07 15:46:37 +02:00
Rodolfo García Peñas (kix)
8b7f8c3cdd
Merge pull request #77 from nicolas33/ns/oauth-str
offlineimap.conf: oauth returned values must be str
2021-08-03 11:25:29 +02:00
Rodolfo García Peñas (kix)
9e12bd93ad
Merge pull request #79 from nicolas33/ns/require-imaplib2
requirements.txt: update imaplib2 version requirement
2021-08-03 11:25:02 +02:00
Nicolas Sebrecht
50a3ee53bf requirements.txt: update imaplib2 version requirement
Fixes #39

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2021-08-03 00:41:22 +02:00
Nicolas Sebrecht
175587634c offlineimap.conf: oauth returned values must be str
Fixes #57.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2021-08-03 00:17:20 +02:00
Rodolfo García Peñas (kix)
87f9507cc9
Merge pull request #75 from thekix/master
Windows patches
2021-07-25 15:58:28 +02:00
Rodolfo García Peñas (kix)
1a0c29a00e OS rename raises an exception on Windows
This patch checks the exception raises by os.rename()
on Windows and provide the same behavior than Linux.

This patch is related to issue #37, issue 5.
This patch sets closes the issue 37.
closes #37
2021-07-25 15:53:09 +02:00
Rodolfo García Peñas (kix)
c305f47e84 OSError does not include __getitem__
This patch removes the issue about using [] with
OSError instances. This es an old method from Python2.

This patch is related to issue #37, issue 4.
2021-07-25 15:53:09 +02:00
Rodolfo García Peñas (kix)
33f3b4b1aa Do not use UNIX signals in Windows
This patch does not use the signals in Windows. just avoid these calls.

This patch is related to issue #37, issue 3.
2021-07-25 15:53:09 +02:00
Rodolfo García Peñas (kix)
09fc0ece61 imaplib2 version function
The new imaplib2 version >= 3.06 includes a function "version()",
and this patch uses the old style __version__ value and the new
function.

This patch is related to issue #37, issue 2.
2021-07-25 15:53:09 +02:00
Rodolfo García Peñas (kix)
a6fd6b1ded Include portalocker in imaplibutil.py
This patch include the usage of portalocker for Windows environments,
because fcntl is not available.

This patch is related to issue #37, issue 1.
2021-07-25 15:50:47 +02:00
Rodolfo García Peñas (kix)
be752838c8
Merge pull request #73 from piyueh/update-doc
update README
2021-06-12 16:11:31 +02:00
Pi-Yueh Chuang
199b8257eb
update README
- moved hyperlinks to the same section
- removed redundant and incorectly-formated Markdown hyperlink
- added the information of offlineimap 3 Arch Linux AUR package
- removed info of installing imaplib2 from its github repo: imaplib2 now
  has a release on PyPI.
2021-06-10 18:16:53 -04:00
Rodolfo García Peñas (kix)
fe443e6bd3
Merge pull request #72 from jishac/encoding_edge_cases
Encoding: edge cases and error handling
2021-06-09 06:03:54 +02:00
Rodolfo García Peñas (kix)
1bb43856fa
Merge pull request #70 from xianwenchen/master
README.md: two improvements
2021-06-09 06:00:37 +02:00
Joseph Ishac
9e0fb59bdf Adding missing import of NoBoundaryInMultipartDefect 2021-06-07 22:18:31 -04:00
Joseph Ishac
5b976fc5da Making error handling when parsing messages consistent 2021-06-07 21:57:54 -04:00
Joseph Ishac
9bebcbe4f7 Adding utilities to Base class.
Moving the quoted boundary fix to the Base class so that it can be used
by any subclass that needs to read an email.  Adding another utility to
extract message-id from a raw email.
2021-06-07 20:26:26 -04:00
Joseph Ishac
b4f100c92c Merge branch to add extra debugging to imap parsing into encoding_edge_cases branch 2021-06-07 14:07:43 -04:00
Joseph Ishac
b0aad911ab Adding some extra error handling when parsing from imaplib 2021-06-07 14:05:07 -04:00
Xianwen Chen
4585ffb6dc README.md:
Previously, the link to releases was pointing to offlineimap. I now point the link to the offlineimap3's releases.
  I added a note explaining how one may install imaplib2 from git repository. This is related to issue #69.
2021-05-10 14:44:27 +00:00
Rodolfo García Peñas (kix)
721d579a32
Merge pull request #66 from duritong/fix-fingerprint-verification
disable verification of ssl certs via CA if fingerpint is set
2021-05-09 11:28:17 +02:00