james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwiederk...@apache.org
Subject svn commit: r880728 - in /james/mime4j/trunk/core/src: main/java/org/apache/james/mime4j/io/MaxHeaderLengthLimitException.java main/java/org/apache/james/mime4j/parser/AbstractEntity.java test/java/org/apache/james/mime4j/parser/MimeEntityTest.java
Date Mon, 16 Nov 2009 12:36:41 GMT
Author: mwiederkehr
Date: Mon Nov 16 12:36:41 2009
New Revision: 880728

URL: http://svn.apache.org/viewvc?rev=880728&view=rev
Log:
Added MaxHeaderLengthLimitException (MIME4J-140).

Added:
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/MaxHeaderLengthLimitException.java
Modified:
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MimeEntityTest.java

Added: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/MaxHeaderLengthLimitException.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/MaxHeaderLengthLimitException.java?rev=880728&view=auto
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/MaxHeaderLengthLimitException.java
(added)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/MaxHeaderLengthLimitException.java
Mon Nov 16 12:36:41 2009
@@ -0,0 +1,35 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mime4j.io;
+
+import org.apache.james.mime4j.MimeException;
+
+/**
+ * Signals a I/O error due to the total header length exceeding the maximum limit.
+ */
+public class MaxHeaderLengthLimitException extends MimeException {
+
+    private static final long serialVersionUID = 8924290744274769913L;
+
+    public MaxHeaderLengthLimitException(final String message) {
+        super(message);
+    }
+
+}

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java?rev=880728&r1=880727&r2=880728&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java
(original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java
Mon Nov 16 12:36:41 2009
@@ -30,6 +30,7 @@
 import org.apache.james.mime4j.descriptor.MaximalBodyDescriptor;
 import org.apache.james.mime4j.descriptor.MutableBodyDescriptor;
 import org.apache.james.mime4j.io.LineReaderInputStream;
+import org.apache.james.mime4j.io.MaxHeaderLengthLimitException;
 import org.apache.james.mime4j.io.MaxHeaderLimitException;
 import org.apache.james.mime4j.io.MaxLineLimitException;
 import org.apache.james.mime4j.util.ByteArrayBuffer;
@@ -136,7 +137,7 @@
                 // copy it to the field buffer
                 int len = linebuf.length();
                 if (maxHeaderLen > 0 && fieldbuf.length() + len >= maxHeaderLen)
{
-                    throw new MaxLineLimitException("Maximum header length limit exceeded");
+                    throw new MaxHeaderLengthLimitException("Maximum header length limit
exceeded");
                 }
                 if (len > 0) {
                     fieldbuf.append(linebuf.buffer(), 0, len);

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MimeEntityTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MimeEntityTest.java?rev=880728&r1=880727&r2=880728&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MimeEntityTest.java
(original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/parser/MimeEntityTest.java
Mon Nov 16 12:36:41 2009
@@ -25,6 +25,7 @@
 import org.apache.commons.io.IOUtils;
 import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.io.BufferedLineReaderInputStream;
+import org.apache.james.mime4j.io.MaxHeaderLengthLimitException;
 import org.apache.james.mime4j.io.MaxHeaderLimitException;
 import org.apache.james.mime4j.io.MaxLineLimitException;
 import org.apache.james.mime4j.io.LineNumberInputStream;
@@ -423,8 +424,7 @@
         try {
             entity.advance();
             fail("MimeException caused by MaxLineLimitException should have been thrown");
-        } catch (MimeException expected) {
-            assertTrue(expected.getCause() instanceof MaxLineLimitException);
+        } catch (MaxHeaderLengthLimitException expected) {
         }
     }
 



Mime
View raw message