* SusiMail:

- Fix encoding in sent mails on non-UTF8 platforms (thx cryptosynthesis)
   - Clean up all other getBytes() calls
   - Tweak spacing on up buttons
This commit is contained in:
zzz
2014-04-22 11:48:45 +00:00
parent b43ebd2486
commit 6986f90bf8
10 changed files with 29 additions and 16 deletions

View File

@ -33,6 +33,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import net.i2p.data.DataHelper;
/**
* @author susi23
*/
@ -145,7 +147,7 @@ class MailPart {
*/
int beginLastPart = -1;
if( multipart ) {
byte boundaryArray[] = boundary.getBytes();
byte boundaryArray[] = DataHelper.getUTF8(boundary);
for( int i = beginBody; i < end - 4; i++ ) {
if( buffer.content[i] == '\r' &&
buffer.content[i+1] == '\n' &&

View File

@ -29,6 +29,8 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import net.i2p.data.DataHelper;
/**
* @author susi
*/
@ -57,7 +59,7 @@ public class Base64 implements Encoding {
*/
public String encode(String str) throws EncodingException {
try {
return encode( new ByteArrayInputStream( str.getBytes() ) );
return encode( new ByteArrayInputStream( DataHelper.getUTF8(str) ) );
}catch (IOException e) {
throw new EncodingException( e.getMessage() );
}
@ -174,7 +176,7 @@ public class Base64 implements Encoding {
* @return Buffer containing a decoded String.
*/
public ReadBuffer decode(String text) throws DecodingException {
return text != null ? decode( text.getBytes() ) : null;
return text != null ? decode( DataHelper.getUTF8(text) ) : null;
}
/**

View File

@ -25,6 +25,8 @@ package i2p.susi.webmail.encoding;
import i2p.susi.util.ReadBuffer;
import net.i2p.data.DataHelper;
/**
* @author susi
*/
@ -72,7 +74,7 @@ public class EightBit implements Encoding {
* @see i2p.susi.webmail.encoding.Encoding#decode(java.lang.String)
*/
public ReadBuffer decode(String str) throws DecodingException {
return decode( str.getBytes() );
return decode( DataHelper.getUTF8(str) );
}
/* (non-Javadoc)

View File

@ -32,6 +32,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;
import net.i2p.data.DataHelper;
/**
* Ref:
* http://en.wikipedia.org/wiki/MIME#Encoded-Word
@ -51,7 +53,7 @@ public class HeaderLine implements Encoding {
* @see i2p.susi.webmail.encoding.Encoding#encode(java.lang.String)
*/
public String encode(String text) throws EncodingException {
return encode( text.getBytes() );
return encode( DataHelper.getUTF8(text) );
}
private static final int BUFSIZE = 2;
/* (non-Javadoc)
@ -216,7 +218,7 @@ public class HeaderLine implements Encoding {
// decode string
String decoded = new String(tmp.content, tmp.offset, tmp.length, charset);
// encode string
byte[] utf8 = decoded.getBytes("UTF-8");
byte[] utf8 = DataHelper.getUTF8(decoded);
for( int j = 0; j < utf8.length; j++ ) {
byte d = utf8[j];
out[written++] = ( d == '_' ? 32 : d );
@ -297,7 +299,7 @@ public class HeaderLine implements Encoding {
}
public ReadBuffer decode(String text) throws DecodingException {
return text != null ? decode( text.getBytes() ) : null;
return text != null ? decode( DataHelper.getUTF8(text) ) : null;
}
/* (non-Javadoc)

View File

@ -30,6 +30,8 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import net.i2p.data.DataHelper;
/**
* @author susi
*/
@ -45,7 +47,7 @@ public class QuotedPrintable implements Encoding {
* @see i2p.susi.webmail.encoding.Encoding#encode(java.lang.String)
*/
public String encode(String text) throws EncodingException {
return encode( text.getBytes() );
return encode( DataHelper.getUTF8(text) );
}
/**
*
@ -111,7 +113,7 @@ public class QuotedPrintable implements Encoding {
* @see i2p.susi.webmail.encoding.Encoding#decode(java.lang.String)
*/
public ReadBuffer decode(String text) {
return text != null ? decode( text.getBytes() ) : null;
return text != null ? decode( DataHelper.getUTF8(text) ) : null;
}
/* (non-Javadoc)

View File

@ -25,6 +25,8 @@ package i2p.susi.webmail.encoding;
import i2p.susi.util.ReadBuffer;
import net.i2p.data.DataHelper;
/**
* @author susi
*/
@ -84,7 +86,7 @@ public class SevenBit implements Encoding {
* @see i2p.susi23.mail.encoding.Encoding#decode(java.lang.String)
*/
public ReadBuffer decode(String str) throws DecodingException {
return decode( str.getBytes() );
return decode( DataHelper.getUTF8(str) );
}
/* (non-Javadoc)

View File

@ -729,7 +729,7 @@ public class POP3MailBox {
msg = "PASS provided";
Debug.debug(Debug.DEBUG, "sendCmd1a(" + msg + ")");
cmd += "\r\n";
socket.getOutputStream().write(cmd.getBytes());
socket.getOutputStream().write(DataHelper.getASCII(cmd));
}
/**

View File

@ -108,7 +108,7 @@ public class SMTPClient {
throw new IOException("no socket");
OutputStream out = socket.getOutputStream();
cmd += "\r\n";
out.write( cmd.getBytes() );
out.write(DataHelper.getASCII(cmd));
}
/**
@ -264,8 +264,8 @@ public class SMTPClient {
if (ok) {
if( body.indexOf( "\r\n.\r\n" ) != -1 )
body = body.replaceAll( "\r\n.\r\n", "\r\n..\r\n" );
socket.getOutputStream().write( body.getBytes() );
socket.getOutputStream().write("\r\n.\r\n".getBytes() );
socket.getOutputStream().write(DataHelper.getUTF8(body));
socket.getOutputStream().write(DataHelper.getASCII("\r\n.\r\n"));
int result = sendCmd(null);
if (result == 250)
mailSent = true;

View File

@ -1,6 +1,7 @@
2014-04-22 zzz
* SusiMail:
- Add persistent cache
- Fix encoding in sent mails on non-UTF8 platforms
2014-04-21 zzz
* SusiMail:

View File

@ -177,8 +177,8 @@ input.delete, input.delete_attachment, input.really_delete {
}
input.download, input.lastpage {
background: #ddf url('/themes/console/images/arrow_down.png') no-repeat 4px center;
padding: 2px 3px 2px 24px;
background: #ddf url('/themes/console/images/arrow_down.png') no-repeat 1px center;
padding: 2px 3px 2px 19px;
min-height: 22px;
}