james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nik...@apache.org
Subject svn commit: r678387 - in /james/mime4j/trunk/src: main/java/org/apache/james/mime4j/util/CodecUtil.java test/java/org/apache/james/mime4j/util/CodecUtilTest.java
Date Mon, 21 Jul 2008 10:36:58 GMT
Author: niklas
Date: Mon Jul 21 03:36:57 2008
New Revision: 678387

URL: http://svn.apache.org/viewvc?rev=678387&view=rev
Log:
Resolved MIME4J-63: CodecUtil.encodeQuotedPrintableBinary() now handles 8bit bytes as expected.

Modified:
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/CodecUtil.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/CodecUtilTest.java

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/CodecUtil.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/CodecUtil.java?rev=678387&r1=678386&r2=678387&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/CodecUtil.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/CodecUtil.java Mon Jul 21
03:36:57 2008
@@ -138,11 +138,14 @@
             if (--nextSoftBreak <= QUOTED_PRINTABLE_OCTETS_PER_ESCAPE) {
                 softBreak();
             }
+            
+            int nextUnsigned = (int) next & 0xff;
+            
             write(EQUALS);
             --nextSoftBreak;
-            write(HEX_DIGITS[next >> 4]);
+            write(HEX_DIGITS[nextUnsigned >> 4]);
             --nextSoftBreak;
-            write(HEX_DIGITS[next % 0x10]);
+            write(HEX_DIGITS[nextUnsigned % 0x10]);
         }
         
         private void write(byte next) throws IOException {

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/CodecUtilTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/CodecUtilTest.java?rev=678387&r1=678386&r2=678387&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/CodecUtilTest.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/CodecUtilTest.java Mon Jul
21 03:36:57 2008
@@ -58,6 +58,15 @@
         String actual = new String(out.toByteArray(), "US-ASCII");
         assertEquals(expected, actual);
     }
+
+    public void testEncodeQuotedPrintableNonAsciiChars() throws Exception {
+        String s = "7bit content with euro \u20AC symbol";
+        InputStream in = new ByteArrayInputStream(s.getBytes("iso-8859-15"));
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        CodecUtil.encodeQuotedPrintableBinary(in, out);
+        String actual = new String(out.toByteArray(), "US-ASCII");
+        assertEquals("7bit=20content=20with=20euro=20=A4=20symbol", actual);
+    }
     
     private void assertEquals(byte[] expected, byte[] actual) {
         StringBuffer buffer = new StringBuffer(expected.length);



---------------------------------------------------------------------
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