Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This code was still very much Python 2 only.
A word on why I used
latin
encoding:This is a synonym for
iso-8859-1
which is the default encoding used in RFC-2831 (Digest MD5 SASL).Now, Digest-MD5 SASL supports UTF-8 too, but with some caveats. As far as I understand, UTF-8 can only be used under the following conditions:
charset=UTF-8
charset=UTF-8
username-value
,realm-value
,passwd
may only be UTF-8 encoded before hashing if they contain any non-ISO-8859-1 character in them, otherwise the hash must be calculated from the ISO-8859-1 encoding.Since none of this logic exists in the current implementation, I decided to only use
latin
. Anything else would be a new feature.Cf. RFC 2831
Note: This is mostly untested because I couldn't connect to my test server that supports Digest-MD5 with sievelib, even after manually switching to PLAIN/LOGIN. It works with other ManageSieve clients, so I assume there is another, perhaps unrelated, bug in this library somewhere. Honestly, I don't have the time to fully track down that issue and will likely be using the other client going forward. However, with these changes, it did at least try to connect without raising random exceptions, so I wanted to at least share my effort.