Permalink
Browse files

MIME4J-189: fixed regression caused by incorrect handling of folded q…

…uoted strings in RawFieldParser

git-svn-id: https://svn.apache.org/repos/asf/james/mime4j/trunk@1095398 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 1384bb9 commit 280a2c9a1f688f8bd7eefc0b794d7e72a9aae3a2 @ok2c ok2c committed Apr 20, 2011
View
4 core/src/main/java/org/apache/james/mime4j/stream/DefaultBodyDescriptor.java
@@ -133,9 +133,7 @@ public void addField(RawField field) throws MimeException {
private void parseContentType(RawField field) throws MimeException {
contentTypeSet = true;
- // TODO this is a temporary fix while MIME4J-189 is fixed for real.
- RawField rf = new RawField(field.getName(), field.getBody());
- RawBody body = RawFieldParser.DEFAULT.parseRawBody(rf);
+ RawBody body = RawFieldParser.DEFAULT.parseRawBody(field);
String main = body.getValue();
Map<String, String> params = new HashMap<String, String>();
for (NameValuePair nmp: body.getParams()) {
View
2 core/src/main/java/org/apache/james/mime4j/stream/RawFieldParser.java
@@ -265,7 +265,7 @@ static void copyQuotedContent(final ByteSequence buf, final ParserCursor cursor,
}
if (current == '\\') {
escaped = true;
- } else {
+ } else if (current != '\r' && current != '\n') {
dst.append(current);
}
}
View
9 core/src/test/java/org/apache/james/mime4j/stream/RawFieldParserTest.java
@@ -427,13 +427,7 @@ public void testRawBodyParseEmptyParam() {
assertEquals("boundary", params.get(1).getValue());
}
- /**
- * Proof for MIME4J-189.
- * Either RawFieldParser implements unfolding or callers of RawFieldParser
- * have to make sure the content is unfolded before being parsed.
- */
- /** TODO fix the main code.
- public void testFoldedContentType() {
+ public void testRawBodyParseFolded() {
ByteSequence buf = ContentUtil.encode(
"multipart/alternative; boundary=\"simple\r\n boundary\"");
RawFieldParser parser = new RawFieldParser();
@@ -446,6 +440,5 @@ public void testFoldedContentType() {
assertEquals("boundary", params.get(0).getName());
assertEquals("simple boundary", params.get(0).getValue());
}
- */
}

0 comments on commit 280a2c9

Please sign in to comment.