Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong newline encoding sievelib.managesieve.Client.getscript ? #95

Open
tacruc opened this issue Jun 9, 2020 · 4 comments
Open

Wrong newline encoding sievelib.managesieve.Client.getscript ? #95

tacruc opened this issue Jun 9, 2020 · 4 comments

Comments

@tacruc
Copy link

tacruc commented Jun 9, 2020

Thanks for the nice library. Saved me some time in creating sieve scripts to handle my emails.

I had the follwing issue

c = Client(server)
c.connect(user, password, starttls=True)
script = c.getscript('Open-Xchange')
c.havespace('Open-Xchange',len(script))
c.putscript('Open-Xchange',script)

Was not working c.havespace returned true, but putscript failed. The Problem was solved by

c = Client(server)
c.connect(user, password, starttls=True)
script = c.getscript('Open-Xchange')
script.replace("\n","\r\n")
c.havespace('Open-Xchange',len(script))
c.putscript('Open-Xchange',script)

Therefore I'm wondering if this should be fixed in the library or if there is a good reason for this behavior.

@tonioo
Copy link
Owner

tonioo commented Jun 10, 2020

@tacruc With your fix, putscript works?

@tacruc
Copy link
Author

tacruc commented Jun 10, 2020

Yes, but I only tested it against the sieve server of mailbox.org and have no broader background of how or why it works. It was just a good guess.

@derula
Copy link
Contributor

derula commented Jun 14, 2020

Note: the parser isn't really set up to work with CRLF linebreaks, so if the getscript behavior is changed, the parser might break. I particularly noticed this with multi-line strings (parser only recognized them if they end on .\n, but with CRLF they would end on .\r\n), but there might be other issues.

It might be a quicker fix to make putscript just convert newlines back to CRLF automatically.

@derula
Copy link
Contributor

derula commented Nov 7, 2020

Addendum: since the Sieve spec is pretty clear about only allowing \r\n linebreaks, I think the best way to comply would be to never convert it to Unix linebreaks to begin with. But this might require some non-trivial changes to the parser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants