Author: bago
Date: Thu Mar 31 10:52:09 2011
New Revision: 1087248

URL: http://svn.apache.org/viewvc?rev=1087248&view=rev
Log:
RFC 3028 says newline is CRLF, so changed parser and tests to follow the rule 
(JSIEVE-75).
Patch contributed by Vishal Mahajan: thank you.

Modified:
    james/jsieve/trunk/main/src/main/jjtree/sieve/sieve.jjt
    
james/jsieve/trunk/main/src/test/java/org/apache/jsieve/MultilineTextTest.java

Modified: james/jsieve/trunk/main/src/main/jjtree/sieve/sieve.jjt
URL: 
http://svn.apache.org/viewvc/james/jsieve/trunk/main/src/main/jjtree/sieve/sieve.jjt?rev=1087248&r1=1087247&r2=1087248&view=diff
==============================================================================
--- james/jsieve/trunk/main/src/main/jjtree/sieve/sieve.jjt (original)
+++ james/jsieve/trunk/main/src/main/jjtree/sieve/sieve.jjt Thu Mar 31 10:52:09 
2011
@@ -138,29 +138,33 @@ TOKEN : /* LITERALS */
   <#MULTI_LINE_START: 
       ("text:")
       ([" ", "\t"])*
-      (<HASH_COMMENT>|<NEWLINE>)
+      (<HASH_COMMENT>|<CRLF>)
   >
 |
   <#MULTI_LINE_END:
-      ("." <NEWLINE>)
+      ("." <CRLF>)
   >              
 |
+  <#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_NEWLINE>)*)?
       <NEWLINE>
   >  
 |
-  < #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,7 +271,9 @@ void string() :
       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);

Modified: 
james/jsieve/trunk/main/src/test/java/org/apache/jsieve/MultilineTextTest.java
URL: 
http://svn.apache.org/viewvc/james/jsieve/trunk/main/src/test/java/org/apache/jsieve/MultilineTextTest.java?rev=1087248&r1=1087247&r2=1087248&view=diff
==============================================================================
--- 
james/jsieve/trunk/main/src/test/java/org/apache/jsieve/MultilineTextTest.java 
(original)
+++ 
james/jsieve/trunk/main/src/test/java/org/apache/jsieve/MultilineTextTest.java 
Thu Mar 31 10:52:09 2011
@@ -37,7 +37,7 @@ public class MultilineTextTest extends T
      */
     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 class MultilineTextTest extends T
      */
     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 class MultilineTextTest extends T
      */
     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 class MultilineTextTest extends T
     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 class MultilineTextTest extends T
     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 @@ public class MultilineTextTest extends T
         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 @@ public class MultilineTextTest extends T
         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());
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to