Index: main/src/test/java/org/apache/jsieve/MultilineTextTest.java =================================================================== --- main/src/test/java/org/apache/jsieve/MultilineTextTest.java (revision 1082147) +++ main/src/test/java/org/apache/jsieve/MultilineTextTest.java (working copy) @@ -37,7 +37,7 @@ */ public void testRejectMultilineMessage() throws Exception { String message = "This is not a love song"; - String script = "reject text:\n" + message + "\n.\n;"; + String script = "reject text:\r\n" + message + "\r\n.\r\n;"; ActionReject rejection = runRejectScript(script); assertEquals(message, rejection.getMessage()); } @@ -48,7 +48,7 @@ */ public void testRejectMultilineMessageWithWhitespace() throws Exception { String message = "This is not a love song"; - String script = "reject text: \t \t \n" + message + "\n.\n;"; + String script = "reject text: \t \t \r\n" + message + "\r\n.\r\n;"; ActionReject rejection = runRejectScript(script); assertEquals(message, rejection.getMessage()); } @@ -59,7 +59,7 @@ */ public void testRejectMultilineMessageWithDotsMidline() throws Exception { String message = "This is not.....a love song"; - String script = "reject text:\n" + message + "\n.\n;"; + String script = "reject text:\r\n" + message + "\r\n.\r\n;"; ActionReject rejection = runRejectScript(script); assertEquals(message, rejection.getMessage()); } @@ -70,7 +70,7 @@ public void testRejectMultilineMessageWithDotStuffing() throws Exception { String lineOne = "This is not\n"; String lineTwo = ".A Love Story"; - String script = "reject text:\n" + lineOne + '.' + lineTwo + "\n.\n;"; + String script = "reject text:\r\n" + lineOne + '.' + lineTwo + "\r\n.\r\n;"; ActionReject rejection = runRejectScript(script); assertEquals(lineOne + lineTwo, rejection.getMessage()); } @@ -81,7 +81,7 @@ public void testRejectMultilineMessageWithMissedDotStuffing() throws Exception { String lineOne = "This is not\n"; String lineTwo = ".A Love Story"; - String script = "reject text:\n" + lineOne + lineTwo + "\n.\n;"; + String script = "reject text:\r\n" + lineOne + lineTwo + "\r\n.\r\n;"; ActionReject rejection = runRejectScript(script); assertEquals(lineOne + lineTwo, rejection.getMessage()); } @@ -93,7 +93,7 @@ String lineOne = "This is line 1.\n"; String lineTwo = "This is line 2.\n"; String lineThree = "........ This is line 3.\n"; - String script = "reject text:\n" + lineOne + lineTwo + '.' + lineThree + "\n.\n;"; + String script = "reject text:\r\n" + lineOne + lineTwo + '.' + lineThree + "\r\n.\r\n;"; ActionReject rejection = runRejectScript(script); assertEquals(lineOne + lineTwo + lineThree, rejection.getMessage()); } @@ -107,7 +107,7 @@ String lineThree = "........ This is line 3.\n"; String lineFour = ".\n"; String lineFive = ".\n"; - String script = "reject text:\n" + lineOne + lineTwo + '.' + lineThree + '.' + lineFour + '.' + lineFive + "\n.\n;"; + String script = "reject text:\r\n" + lineOne + lineTwo + '.' + lineThree + '.' + lineFour + '.' + lineFive + "\r\n.\r\n;"; ActionReject rejection = runRejectScript(script); assertEquals(lineOne + lineTwo + lineThree + lineFour + lineFive, rejection.getMessage()); } Index: main/src/main/jjtree/sieve/sieve.jjt =================================================================== --- main/src/main/jjtree/sieve/sieve.jjt (revision 1082147) +++ main/src/main/jjtree/sieve/sieve.jjt (working copy) @@ -138,29 +138,33 @@ <#MULTI_LINE_START: ("text:") ([" ", "\t"])* - (|) + (|) > | <#MULTI_LINE_END: - ("." ) + ("." ) > | + <#CRLF: + ("\r\n") + > +| <#NEWLINE: ("\n"|"\r"|"\r\n") > -| +| // multi-line-literal = [CHAR-NOT-DOT *CHAR_NOT_NEWLINE] NEWLINE < #MULTI_LINE_LITERAL: ( ()*)? > | - < #CHAR_NOT_DOT: - (~["."]) + < #CHAR_NOT_DOT: + (~[".","\n","\r"]) > | < #CHAR_NOT_NEWLINE: - (~["\n"] | ("\r" ~["\n"])) + (~["\n","\r"]) > | // multi-line-dotstuff = "." 1*CHAR-NOT-CRLF CRLF @@ -267,10 +271,12 @@ while (builder.length()>0 && builder.charAt(0) != '\n') { builder.deleteCharAt(0); } - // remove suffixing newline-dot-newline + // remove suffixing CRLF-dot-CRLF builder.deleteCharAt(builder.length() - 1); builder.deleteCharAt(builder.length() - 1); builder.deleteCharAt(builder.length() - 1); + builder.deleteCharAt(builder.length() - 1); + builder.deleteCharAt(builder.length() - 1); int nextStuffedDot = builder.indexOf("\n.."); while (nextStuffedDot >= 0) {