Allow operation names to be escaped in URL
This commit is contained in:
parent
adeb15809b
commit
81cb769d18
|
@ -78,6 +78,7 @@ import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor;
|
|||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import ca.uhn.fhir.util.CoverageIgnore;
|
||||
import ca.uhn.fhir.util.ReflectionUtil;
|
||||
import ca.uhn.fhir.util.UrlPathTokenizer;
|
||||
import ca.uhn.fhir.util.UrlUtil;
|
||||
import ca.uhn.fhir.util.VersionUtil;
|
||||
|
||||
|
@ -913,7 +914,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
|||
}
|
||||
|
||||
public void populateRequestDetailsFromRequestPath(RequestDetails theRequestDetails, String theRequestPath) {
|
||||
StringTokenizer tok = new StringTokenizer(theRequestPath, "/");
|
||||
StringTokenizer tok = new UrlPathTokenizer(theRequestPath);
|
||||
String resourceName = null;
|
||||
|
||||
IIdType id = null;
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package ca.uhn.fhir.util;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
public class UrlPathTokenizer extends StringTokenizer {
|
||||
|
||||
public UrlPathTokenizer(String theRequestPath) {
|
||||
super(theRequestPath, "/");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String nextToken() {
|
||||
return UrlUtil.unescape(super.nextToken());
|
||||
}
|
||||
|
||||
@CoverageIgnore
|
||||
@Override
|
||||
public String nextToken(String theDelim) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@CoverageIgnore
|
||||
@Override
|
||||
public Object nextElement() {
|
||||
return super.nextElement();
|
||||
}
|
||||
|
||||
}
|
|
@ -118,6 +118,19 @@ public class OperationServerWithSearchParamTypesDstu3Test {
|
|||
assertEquals("type $orlist", ourLastMethod);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEscapedOperationName() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/%24andlist?valstr=VALSTR1A,VALSTR1B&valstr=VALSTR2A,VALSTR2B&valtok=" + UrlUtil.escape("VALTOK1A|VALTOK1B") + "&valtok=" + UrlUtil.escape("VALTOK2A|VALTOK2B"));
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
String response = IOUtils.toString(status.getEntity().getContent());
|
||||
ourLog.info(response);
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
|
||||
assertEquals(2, ourLastParamValStr.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAndListWithUrl() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/$andlist?valstr=VALSTR1A,VALSTR1B&valstr=VALSTR2A,VALSTR2B&valtok=" + UrlUtil.escape("VALTOK1A|VALTOK1B") + "&valtok=" + UrlUtil.escape("VALTOK2A|VALTOK2B"));
|
||||
|
|
|
@ -145,6 +145,11 @@
|
|||
some resources using the official validator
|
||||
rules.
|
||||
</action>
|
||||
<action type="fix">
|
||||
Server failed to invoke operations when the name
|
||||
was escaped (%24execute instead of $execute).
|
||||
Thanks to Michael Lawley for reporting!
|
||||
</action>
|
||||
</release>
|
||||
<release version="1.5" date="2016-04-20">
|
||||
<action type="fix" issue="339">
|
||||
|
|
Loading…
Reference in New Issue