james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwiederk...@apache.org
Subject svn commit: r738056 - in /james/mime4j/trunk/src: main/java/org/apache/james/mime4j/codec/EncoderUtil.java test/java/org/apache/james/mime4j/codec/EncoderUtilTest.java test/java/org/apache/james/mime4j/field/FieldsTest.java
Date Tue, 27 Jan 2009 11:22:11 GMT
Author: mwiederkehr
Date: Tue Jan 27 11:22:09 2009
New Revision: 738056

URL: http://svn.apache.org/viewvc?rev=738056&view=rev
Log:
MIME4J-100: change threshold of EncoderUtil.hasToBeEncoded to 77 characters; one character
has to reserved for a possible folding white space.

Modified:
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/codec/EncoderUtil.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/codec/EncoderUtilTest.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/FieldsTest.java

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/codec/EncoderUtil.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/codec/EncoderUtil.java?rev=738056&r1=738055&r2=738056&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/codec/EncoderUtil.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/codec/EncoderUtil.java Tue Jan
27 11:22:09 2009
@@ -181,7 +181,7 @@
      * Determines if the specified string has to encoded into an encoded-word.
      * Returns <code>true</code> if the text contains characters that don't
      * fall into the printable ASCII character set or if the text contains a
-     * 'word' (sequence of non-whitespace characters) longer than 78 characters
+     * 'word' (sequence of non-whitespace characters) longer than 77 characters
      * (including characters already used up in the line).
      * 
      * @param text
@@ -205,10 +205,11 @@
                 nonWhiteSpaceCount = 0;
             } else {
                 nonWhiteSpaceCount++;
-                if (nonWhiteSpaceCount > 78) {
-                    // line cannot be folded into multiple lines with no more
-                    // than 78 characters each. encoding as encoded-words makes
-                    // that possible.
+                if (nonWhiteSpaceCount > 77) {
+                    // Line cannot be folded into multiple lines with no more
+                    // than 78 characters each. Encoding as encoded-words makes
+                    // that possible. One character has to be reserved for
+                    // folding white space; that leaves 77 characters.
                     return true;
                 }
 

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/codec/EncoderUtilTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/codec/EncoderUtilTest.java?rev=738056&r1=738055&r2=738056&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/codec/EncoderUtilTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/codec/EncoderUtilTest.java Tue
Jan 27 11:22:09 2009
@@ -76,9 +76,9 @@
         assertTrue(EncoderUtil.hasToBeEncoded("non-printable ascii: \010", 0));
         assertTrue(EncoderUtil.hasToBeEncoded("non-ascii: \u20ac", 0));
 
-        assertFalse(EncoderUtil.hasToBeEncoded("1234567890123456789012345678",
+        assertFalse(EncoderUtil.hasToBeEncoded("123456789012345678901234567",
                 50));
-        assertTrue(EncoderUtil.hasToBeEncoded("12345678901234567890123456789",
+        assertTrue(EncoderUtil.hasToBeEncoded("1234567890123456789012345678",
                 50));
         assertFalse(EncoderUtil.hasToBeEncoded(
                 "\t12345678901234567890123456789", 50));

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/FieldsTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/FieldsTest.java?rev=738056&r1=738055&r2=738056&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/FieldsTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/FieldsTest.java Tue Jan
27 11:22:09 2009
@@ -159,14 +159,14 @@
         assertEquals("Subject: =?ISO-8859-1?Q?Sm=F8rebr=F8d?=", Fields.subject(
                 "Sm\370rebr\370d").getRaw());
 
-        String seventyNine = "123456789012345678901234567890123456789012345678901234567890123456789";
-        assertEquals("Subject: " + seventyNine, Fields.subject(seventyNine)
+        String seventyEight = "12345678901234567890123456789012345678901234567890123456789012345678";
+        assertEquals("Subject: " + seventyEight, Fields.subject(seventyEight)
                 .getRaw());
 
-        String eighty = seventyNine + "0";
-        String expected = "Subject: =?US-ASCII?Q?12345678901234567890123456789012345?="
-                + "\r\n =?US-ASCII?Q?67890123456789012345678901234567890?=";
-        assertEquals(expected, Fields.subject(eighty).getRaw());
+        String seventyNine = seventyEight + "9";
+        String expected = "Subject: =?US-ASCII?Q?1234567890123456789012345678901234?="
+                + "\r\n =?US-ASCII?Q?56789012345678901234567890123456789?=";
+        assertEquals(expected, Fields.subject(seventyNine).getRaw());
     }
 
     public void testSender() throws Exception {



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


Mime
View raw message