Author: olegk
Date: Tue Apr 19 14:53:36 2011
New Revision: 1095104
URL: http://svn.apache.org/viewvc?rev=1095104&view=rev
Log:
Moved presence of whitespace chars in boundary check from
MimeBoundaryInputStream's constructor to MimeEntity where this protocol
violation can be hanlded leniently depending on the parsing mode
Modified:
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/MimeBoundaryInputStream.java
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/Event.java
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntity.java
Modified:
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/MimeBoundaryInputStream.java
URL:
http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/MimeBoundaryInputStream.java?rev=1095104&r1=1095103&r2=1095104&view=diff
==============================================================================
---
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/MimeBoundaryInputStream.java
(original)
+++
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/MimeBoundaryInputStream.java
Tue Apr 19 14:53:36 2011
@@ -77,9 +77,6 @@ public class MimeBoundaryInputStream ext
this.boundary[1] = (byte) '-';
for (int i = 0; i < boundary.length(); i++) {
byte ch = (byte) boundary.charAt(i);
- if (ch == '\r' || ch == '\n') {
- throw new IllegalArgumentException("Boundary may not contain
CR or LF");
- }
this.boundary[i + 2] = ch;
}
Modified:
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/Event.java
URL:
http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/Event.java?rev=1095104&r1=1095103&r2=1095104&view=diff
==============================================================================
---
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/Event.java
(original)
+++
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/Event.java
Tue Apr 19 14:53:36 2011
@@ -38,6 +38,9 @@ public final class Event {
/** Indicates that an obsolete syntax header has been detected */
public static final Event OBSOLETE_HEADER
= new Event("Obsolete header encountered");
+ /** Indicates that while space characters have been found in the boundary
*/
+ public static final Event WHITESPACE_IN_BOUNDARY
+ = new Event("Boundary may not contain CR or LF");
private final String code;
Modified:
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntity.java
URL:
http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntity.java?rev=1095104&r1=1095103&r2=1095104&view=diff
==============================================================================
---
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntity.java
(original)
+++
james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntity.java
Tue Apr 19 14:53:36 2011
@@ -32,6 +32,7 @@ import org.apache.james.mime4j.io.LineNu
import org.apache.james.mime4j.io.LineReaderInputStream;
import org.apache.james.mime4j.io.LineReaderInputStreamAdaptor;
import org.apache.james.mime4j.io.MimeBoundaryInputStream;
+import org.apache.james.mime4j.util.CharsetUtil;
import org.apache.james.mime4j.util.MimeUtil;
class MimeEntity extends AbstractEntity {
@@ -212,12 +213,14 @@ class MimeEntity extends AbstractEntity
private void createMimePartStream() throws MimeException, IOException {
String boundary = body.getBoundary();
- try {
- currentMimePartStream = new MimeBoundaryInputStream(inbuffer,
boundary);
- } catch (IllegalArgumentException e) {
- // thrown when boundary is too long
- throw new MimeException(e.getMessage(), e);
+ for (int i = 0; i < boundary.length(); i++) {
+ char ch = boundary.charAt(i);
+ if (CharsetUtil.isWhitespace(ch)) {
+ monitor(Event.WHITESPACE_IN_BOUNDARY);
+ break;
+ }
}
+ currentMimePartStream = new MimeBoundaryInputStream(inbuffer,
boundary);
dataStream = new LineReaderInputStreamAdaptor(
currentMimePartStream,
config.getMaxLineLen());