SWS-595 - SoapUtils.setActionInContentType incorrectly replaces existing actions
This commit is contained in:
@@ -79,7 +79,7 @@ public abstract class SoapUtils {
|
||||
Matcher matcher = ACTION_PATTERN.matcher(contentType);
|
||||
if (matcher.find() && matcher.groupCount() == 1) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
matcher.appendReplacement(buffer, action);
|
||||
matcher.appendReplacement(buffer, "action=" + action);
|
||||
matcher.appendTail(buffer);
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
@@ -34,6 +34,10 @@ public class SoapUtilsTest extends TestCase {
|
||||
contentType = "application/soap+xml; action=" + soapAction + " ; charset=UTF-8";
|
||||
result = SoapUtils.extractActionFromContentType(contentType);
|
||||
assertEquals("Invalid SOAP action", soapAction, result);
|
||||
|
||||
contentType = "application/soap+xml; charset=UTF-8; action=" + soapAction;
|
||||
result = SoapUtils.extractActionFromContentType(contentType);
|
||||
assertEquals("Invalid SOAP action", soapAction, result);
|
||||
}
|
||||
|
||||
public void testEscapeAction() throws Exception {
|
||||
@@ -51,4 +55,18 @@ public class SoapUtilsTest extends TestCase {
|
||||
|
||||
}
|
||||
|
||||
public void testSetActionInContentType() throws Exception {
|
||||
String soapAction = "http://springframework.org/spring-ws/Action";
|
||||
String contentType = "application/soap+xml";
|
||||
|
||||
String result = SoapUtils.setActionInContentType(contentType, soapAction);
|
||||
assertEquals("Invalid SOAP action", soapAction, SoapUtils.extractActionFromContentType(result));
|
||||
|
||||
String anotherSoapAction = "http://springframework.org/spring-ws/AnotherAction";
|
||||
String contentTypeWithAction = "application/soap+xml; action=http://springframework.org/spring-ws/Action";
|
||||
result = SoapUtils.setActionInContentType(contentTypeWithAction, anotherSoapAction);
|
||||
assertEquals("Invalid SOAP action", anotherSoapAction, SoapUtils.extractActionFromContentType(result));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user