Author: dkulp
Date: Tue Jan 19 18:20:18 2010
New Revision: 900883
URL: http://svn.apache.org/viewvc?rev=900883&view=rev
Log:
Merged revisions 900874 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r900874 | dkulp | 2010-01-19 13:13:46 -0500 (Tue, 19 Jan 2010) | 1 line
[CXF-2623] Add MULTILINE flag for attachment boundary finder
........
Modified:
cxf/branches/2.2.x-fixes/ (props changed)
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
Propchange: cxf/branches/2.2.x-fixes/
('svn:mergeinfo' removed)
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java?rev=900883&r1=900882&r2=900883&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
(original)
+++
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
Tue Jan 19 18:20:18 2010
@@ -55,7 +55,7 @@
// TODO: Is there a better way to detect boundaries in the message content?
// It seems constricting to assume the boundary will start with ----=_Part_
private static final Pattern INPUT_STREAM_BOUNDARY_PATTERN =
- Pattern.compile("^--(\\S*)");
+ Pattern.compile("^--(\\S*)$", Pattern.MULTILINE);
private boolean lazyLoading = true;
Modified:
cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java?rev=900883&r1=900882&r2=900883&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
(original)
+++
cxf/branches/2.2.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
Tue Jan 19 18:20:18 2010
@@ -24,6 +24,8 @@
import java.io.PushbackInputStream;
import java.util.Collection;
import java.util.Iterator;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
@@ -52,6 +54,37 @@
}
@Test
+ public void testNoBoundaryInCT() throws Exception {
+ //CXF-2623
+ String message = "SomeHeader: foo\n"
+ + "------=_Part_34950_1098328613.1263781527359\n"
+ + "Content-Type: text/xml; charset=UTF-8\n"
+ + "Content-Transfer-Encoding: binary\n"
+ + "Content-Id:
<318731183421.1263781527359.ibm.webservi...@auhpap02>\n"
+ + "\n"
+ + "<envelope/>\n"
+ + "------=_Part_34950_1098328613.1263781527359\n"
+ + "Content-Type: text/xml\n"
+ + "Content-Transfer-Encoding: binary\n"
+ + "Content-Id: <b86a5f2d-e7af-4e5e-b71a-9f6f2307cab0>\n"
+ + "\n"
+ + "<message>\n"
+ + "------=_Part_34950_1098328613.1263781527359--";
+
+ Matcher m = Pattern.compile("^--(\\S*)$").matcher(message);
+ Assert.assertFalse(m.find());
+ m = Pattern.compile("^--(\\S*)$", Pattern.MULTILINE).matcher(message);
+ Assert.assertTrue(m.find());
+
+ msg = new MessageImpl();
+ msg.setContent(InputStream.class, new
ByteArrayInputStream(message.getBytes("UTF-8")));
+ msg.put(Message.CONTENT_TYPE, "multipart/related");
+ AttachmentDeserializer ad = new AttachmentDeserializer(msg);
+ ad.initializeAttachments();
+ assertEquals(1, msg.getAttachments().size());
+ }
+
+ @Test
public void testLazyAttachmentCollection() throws Exception {
InputStream is = getClass().getResourceAsStream("mimedata2");
String ct = "multipart/related; type=\"application/xop+xml\"; "
@@ -331,6 +364,5 @@
InputStream inputStreamWithoutAttachments =
message.getContent(InputStream.class);
SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
parser.parse(inputStreamWithoutAttachments, new DefaultHandler());
- System.out.println("All done.");
}
}
\ No newline at end of file