summaryrefslogtreecommitdiff
path: root/alot/db/utils.py
Commit message (Collapse)AuthorAge
* py3k: remove basestring and unicode.Dylan Baker2018-03-01
| | | | This probably isn't completely right, but it's a start.
* py3k: use StringIO from io module instead of cStringIODylan Baker2018-03-01
| | | | | cStringIO doesn't exist in python 3.x, instead one simply uses io.StringIO and python provided a C accelerated version if possible.
* ignore multipart subparts when extracting contentPatrick Totzke2018-01-02
| | | | | these are internal nodes in the mail tree and do not contain displayable content.
* mark inline part as attachment if no mailcap entry is foundPatrick Totzke2018-01-02
|
* Merge branch 'master' into fix/spellingPatrick Totzke2017-09-02
|\
| * db/utils: Update docstring for extract_bodyDylan Baker2017-08-28
| | | | | | | | | | add returns and rtype for sphinx and reflow the rest of the docstring a bit.
| * db/utils: Don't mark signature valid if there is no key to verifyDylan Baker2017-08-23
| |
* | Fix some spelling mistakesLucas Hoffmann2017-09-02
|/
* Use io.BytesIO and io.StringIODylan Baker2017-08-19
| | | | | | | | In python3 StringIO and cStringIO are gone. In their place are io.BytesIO and io.StringIO. They are somewhat different in that they are not separated on implementation, but on the type they emulated. BytesIO works like the bytes class (str in python 2), while StringIO works like the str class (unicode in python2).
* db/utils: Allow encrypted messages to be put in mixed payloads as wellDylan Baker2017-08-17
| | | | | | | | Since a multipart/mixed can contain anything that a normal message could, this should be allowed. The only case that I can think of this actually happening is if an email server takes the original message, puts it in a multipart/mixed, and then attaches it's own message, like on of the annoying "this mail scanned for viruses by <product>".
* db/utils: Handle multipart/signed inside multipart/mixedDylan Baker2017-08-17
| | | | | | | | It is possible (and actual mail clients such as kmail do) to embed a multipart/signed within a multipart/mixed (this is briefly mentioned in the acknowledgements of RFC 3156, and is perfectly valid according to RFC 1341, which says that a multipart/mixed is exactly like a top level message, except that the header may be empty.
* db/utils: Don't attach invalid signature to unsigned but encrypted messagesDylan Baker2017-08-17
| | | | | | The logic in the comment is faulty. There are perfectly legitimate reasons to encrypt but not sign a message, some of them are fleshed out in the previous commit.
* convert from pygpgme to the python "gpg" moduleDaniel Kahn Gillmor2017-08-14
| | | | | | | | | | | | | | | This converts from the now abandoned pygpgme project for wrapping gpgme, to the upstream gpgme python bindings (which are descended from the pyme project, before they became official). Largely this change should not be user visible, but there are a couple cases where the new bindings provide slightly more detailed error messages, and alot directly presents those messages to users. This patch has been significantly revised and updated by Dylan Baker, but was originally authored by Daniel Kahn Gillmor. Fixes #1069
* settings: do not store SettingsManager instance in __init__.pyDylan Baker2017-08-03
| | | | | | | This can create circular imports in unittests, which causes difficult to debug errors. Fixes #1076
* db/utils: Improve readabilityDylan Baker2017-07-24
| | | | | Nested ternaries are awful to read, especially in this case. Putting it into an if statement is actually more terse, and is much easier to read.
* db/utils: optimize if statementsDylan Baker2017-07-24
| | | | | | 1) dont use len() to test that a list is non-empty 2) only go down the else clause if it's possible to have a valid signature.
* db/utils: Support unicode in signaturesDylan Baker2017-07-24
| | | | | | Currently if a signature name has a non-ascii unicode character in it, the thread will fail to load because a UnicodeEncodeError. This patch fixes that by converting the str into unicode.
* utils: Fix verifying signaturesDylan Baker2017-07-11
| | | | | | | | | To verify the signature correctly we need to ensure that the body of the message is decoded the same way as it was when it was signed, specifically using helper.email_as_string to insert \r\n instead of .as_string, which only inserts \n. Fixes #1079
* Use stdlib functions in db.utils.encode_headerLucas Hoffmann2017-06-30
| | | | | | | Instead of manual parsing with regexp and manual string formatting the functions from email.utils are used. This fixes some small inconsistencies with addresses with empty realnames and with commas in realnames.
* alot/db/utils: Revert use of iterkeys on MessageDylan Baker2017-02-02
| | | | Message doesn't have an iterkeys method, just a keys method.
* Use absolute_imports from __future__Lucas Hoffmann2017-01-18
|
* db/utils: fix bad hanging indentDylan Baker2016-12-27
|
* Replace unused arguments with _Dylan Baker2016-12-21
| | | | | | | | | | This patch replaces a large number (but not all) unused arguments with the standard ``_`` placeholder. This has the advantage of signaling that these values are unused. There are a number of places that I've chosen not to apply this, largely in methods that have publicly define signatures that they inherit (usually from urwid).
* Use dict's iter methodsDylan Baker2016-12-21
| | | | | | | | This patch replaces a number of uses of dict.items, dict.values, and dict.keys with their iterative siblings. The advantage of using the iterator version is that they don't copy the keys, values, or items, but simply return references. This reduces memory usage and may speed up the these operations a bit.
* Replace map() and filter() with comprehensionsDylan Baker2016-12-21
| | | | | | | | This had the advantage of being more readable to people without a functional programming background, and it avoids the need to use lambdas which are both slow and have many corners in python. In a few cases it also allows us to use a generator expression instead of a materialized list, which save some memory.
* Use raw strings with backslashesDylan Baker2016-12-21
| | | | This just adds the `r` prefix to a few strings.
* Use with blocks to write to temp filesLucas Hoffmann2016-12-18
|
* Don't pass None as second argument of dict.get()Dylan Baker2016-12-13
| | | | This is the default value.
* Replace mutable keyword argumentsDylan Baker2016-12-13
| | | | | | | | | | | | | | | | | | | | | | | There are a number of cases of mutable keyword arguments (list and dict in this case). Mutable keyword arguments are rather dangerous, since any mutation of the default value is persistent, which will inevitably lead to bugs. For example, imagine this code: def func(def=[]): def.append('foo') return def >>> func() ['foo'] >>> func() ['foo', 'foo'] This is almost certainly not what was intended. This code generally uses the idiom of setting the default value to None, and then assigning with or `value = value or []` which will replace value with the empty list (or dict) when value is falsey, like None or another empty list.
* Clean up importsLucas Hoffmann2016-12-09
| | | | | | - use relative imports if possible - group imports into standard library, third party, and alot modules - sort imports alphabetically
* Use logging's native string interpolationLucas Hoffmann2016-12-09
|
* Merge pull request #752 from jkoelker/pipeto_field_keyPatrick Totzke2016-12-06
|\ | | | | Allow specifing the mailcap field key for `pipeto`
| * Allow specifing the mailcap field key for `pipeto`Jason Kölker2015-02-11
| | | | | | | | | | When decoding the message, use the mailcap field specified for command lookup.
* | Merge branch '0.3.8-feature-untrusted-signatures-858'Patrick Totzke2016-12-06
|\ \
| * | Define local var in all code paths.Lucas Hoffmann2016-03-30
| | |
| * | Indicate untrusted PGP signatures in thread view.Lucas Hoffmann2016-03-24
| | |
* | | fix #891Patrick Totzke2016-10-19
|/ /
* / pep8 fixesPatrick Totzke2015-12-16
|/
* fix regex for unquoting in decode_headerTomas Tomecek2015-01-08
| | | | issue #539
* just formating (pep8 etc.)Patrick Totzke2014-08-02
|
* add mailto-helperPatrick Totzke2013-12-01
|
* db.utils: Use unicode for GPG error messagesSimon Chopin2013-08-13
| | | | | This patch makes the use of unicode more consistent, and enforces the UTF8 charset for the added payload in case of failure.
* Use Unicode strings when dealing with GPGSimon Chopin2013-07-24
| | | | | This delays the encoding of special chars, if any, to the actual display which is supposed to know into what it should be encoded.
* pep8&pyflakes fixesPatrick Totzke2013-07-07
| | | | mostly automatically fixed
* add helper to check if path is below anotherPatrick Totzke2013-07-07
| | | | this is used in the Database manager
* Fix the default failobj of get_paramsJustus Winter2013-06-20
| | | | | | | | | Formerly None was used as failobj, but None is not iterable and that is all that get_params does. Use list() instead which is iterable. Closes #626. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* Tune the parsing of RFC 3156 style mailsJustus Winter2013-06-16
| | | | | | | | | Formerly any SMIME signed mail triggered a malformed OpenPGP message warning. Be more selective wrt what to interpret as OpenPGP data by looking at the protocol parameter first. Includes minor stylistic changes. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* Fix detection of OpenPGP encrypted dataJustus Winter2013-06-16
| | | | | | | Fix detection of OpenPGP encrypted data and also check the 'protocol' parameter. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* Move the parameter extraction to its own functionJustus Winter2013-06-16
| | | | | | | Move the parameter extraction to its own function and generalize it so it can be reused. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>
* Normalize Content-Type parametersJustus Winter2013-06-16
| | | | | | | RFC 2045 specifies that parameter names are case-insensitive, so normalize them by converting them to their lower case version. Signed-off-by: Justus Winter <4winter@informatik.uni-hamburg.de>