You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2014/04/10 04:42:01 UTC
svn commit: r1586199 -
/commons/proper/net/trunk/src/main/java/examples/mail/IMAPImportMbox.java
Author: sebb
Date: Thu Apr 10 02:42:00 2014
New Revision: 1586199
URL: http://svn.apache.org/r1586199
Log:
Unescape >+From_ lines, not just >From_
Modified:
commons/proper/net/trunk/src/main/java/examples/mail/IMAPImportMbox.java
Modified: commons/proper/net/trunk/src/main/java/examples/mail/IMAPImportMbox.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/examples/mail/IMAPImportMbox.java?rev=1586199&r1=1586198&r2=1586199&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/examples/mail/IMAPImportMbox.java (original)
+++ commons/proper/net/trunk/src/main/java/examples/mail/IMAPImportMbox.java Thu Apr 10 02:42:00 2014
@@ -25,6 +25,8 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.apache.commons.net.imap.IMAPClient;
import org.apache.commons.net.imap.IMAPSClient;
@@ -48,6 +50,7 @@ public final class IMAPImportMbox
{
private static final String CRLF = "\r\n";
+ private static final Pattern PATFROM = Pattern.compile(">+From "); // escaped From
public static void main(String[] args) throws IOException
{
@@ -175,7 +178,7 @@ public final class IMAPImportMbox
sb.setLength(0);
total ++;
wanted = wanted(total, line, msgNums, contains);
- } else if (line.startsWith(">From ")) { // Unescape "From " in body text
+ } else if (startsWith(line, PATFROM)) { // Unescape ">+From " in body text
line = line.substring(1);
}
// TODO process first Received: line to determine arrival date?
@@ -200,6 +203,11 @@ public final class IMAPImportMbox
System.out.println("Processed " + total + " messages, loaded " + loaded);
}
+ private static boolean startsWith(String input, Pattern pat) {
+ Matcher m = pat.matcher(input);
+ return m.lookingAt();
+ }
+
private static boolean process(final StringBuilder sb, final IMAPClient imap, final String folder
,final int msgNum) throws IOException {
final int length = sb.length();