tonioo / sievelib

Client-side Sieve and Managesieve library written in Python.
MIT License
46 stars 24 forks source link

checkscript() wrongly encodes non-ascii text #89

Open e1fueg0 opened 4 years ago

e1fueg0 commented 4 years ago

When content takes more bytes than chars, the following command wrongly encodes text:

        content = tools.to_bytes(
            u"{%d+}%s%s" % (len(content), str(CRLF), content))

This code works correctly:

        content = tools.to_bytes(content)
        len1 = tools.to_bytes(u"{%d+}" % len(content))
        content = len1 + CRLF + content
e1fueg0 commented 4 years ago

And also pls propagate out server message in case of error.

e1fueg0 commented 4 years ago

Also pls expose the data from putscript(). And the code can be taken from putscript() to fix checkscript().

        content = tools.to_bytes(content)
        content = tools.to_bytes("{%d+}" % len(content)) + CRLF + content
tonioo commented 4 years ago

@e1fueg0 Sorry to react so lately but could you please make a PR with your modifications?