dburkart / check-sieve

Syntax checker for mail sieves.
MIT License
34 stars 7 forks source link

CR/LF line endings should be supported #51

Closed jeremyp3 closed 1 year ago

jeremyp3 commented 1 year ago

Hello,

I'm really sorry to post this problem, but I don't understand how it works

  1. I cloned the repository
  2. I installed g++ on my debian system and built with make.
  3. it generated me a "check-sieve" executable
  4. I give it a .sieve file that I know is valid.

at this point, I get a response:

jeremy@jerem-debian:~/git/check-sieve (master) $ ./check-sieve /tmp/managesieve.sieve Errors found in "/tmp/managesieve.sieve":

invalid character On line 1: require ["fileinto","regex"]; ^ jeremy@jerem-debian:~/git/check-sieve (master) $

I think I'm forgetting something, but I don't see what :(

i've read the readme several times, but i must be missing something. i don't think i should care what's in the tests folder

thanks for the help !

dburkart commented 1 year ago

Hi Jeremy! Would you mind posting your sieve script to help me debug? Or a reduced version that exhibits the problem would work as well.

I don't see anything wrong with what you did :)

jeremyp3 commented 1 year ago

hello,

with this little sieve script, I have the problem.

I tried to delete the unnecessary requirements but I still have the problem. managesieve.txt

dburkart commented 1 year ago

Very strange. It works for me on a mac using clang:

λ › cat managesieve.txt                             
require ["fileinto"];

# rule:[spam-flag]
if header :contains "X-Spam" "Yes" {
    fileinto "Junk";
}
λ › ./check-sieve managesieve.txt                   
managesieve.txt: No errors found!

I will try to reproduce in a similar environment to yours. What are the versions of g++ and debian that you are running?

jeremyp3 commented 1 year ago

build.txt hello, debian 12 g++ 4:12.2.0-3
here is the result of my build in attachment

dburkart commented 1 year ago

Ahh, I see the problem actually (I wasn't able to reproduce because I copy-pasted your sieve, but if I just use the file provided I can)-- looks like your sieve has CRLF line endings instead of Unix-style newlines.

Reading the spec, looks like this is something we should support.

jeremyp3 commented 1 year ago

I confirm, that everything works after changing the end of line type.

Thanks for the help and the future fix, I must admit that I didn't pay attention to this case when I proposed my file to him

dburkart commented 1 year ago

This should be resolved on master. @jeremyp3 let me know if this fix doesn't work for you!