-
Bug
-
Resolution: Done
-
Major
-
3.0.10.Final
-
None
-
- Enable Jackson2JsonpInterceptor
- Call any GET method which returns some json using ResteasyJackson2Provider
- Add ?callback=foo to the request
- Response will be incorrect
-
Low
Jackson2JsonpInterceptor does not render closing bracket
So
foo({"foo":"bar"}
Is rendered instead of
foo({"foo":"bar"})
The problem is in this method:
Jackson2JsonpInterceptor.java
@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
String function = uri.getQueryParameters().getFirst(callbackQueryParameter);
if (function != null && !function.trim().isEmpty() && !jsonpCompatibleMediaTypes.getPossible(context.getMediaType()).isEmpty()){
OutputStreamWriter writer = new OutputStreamWriter(context.getOutputStream());
writer.write(function + "(");
writer.flush();
context.proceed();
writer.write(")");
writer.flush();
} else {
context.proceed();
}
}
context.proceed() call can close the underlying OutputStream and the bracket appended on the next line will be ignored