提交 bd4d1578 编写于 作者: J Jesse Glick

[JENKINS-27607] Noting merge of #1623.

......@@ -55,6 +55,9 @@ Upcoming changes</a>
<!-- Record your changes in the trunk here. -->
<div id="trunk" style="display:none"><!--=TRUNK-BEGIN=-->
<ul class=image>
<li class=bug>
JSONP served with the wrong MIME type and rejected by Chrome.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-27607">issue 27607</a>)
<li class=bug>
Security file pattern whitelist was broken for some plugins since 1.597.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-27055">issue 27055</a>)
......
......@@ -208,7 +208,7 @@ public class Api extends AbstractModelObject {
public void doJson(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
if (req.getParameter("jsonp") == null || permit(req)) {
setHeaders(rsp);
rsp.serveExposedBean(req,bean, Flavor.JSON);
rsp.serveExposedBean(req,bean, req.getParameter("jsonp") == null ? Flavor.JSON : Flavor.JSONP);
} else {
rsp.sendError(HttpURLConnection.HTTP_FORBIDDEN, "jsonp forbidden; implement jenkins.security.SecureRequester");
}
......
......@@ -49,6 +49,14 @@ public class ApiTest {
j.createWebClient().goTo("api/xml?xpath=/*[1]", "application/xml");
}
@Issue("JENKINS-27607")
@Test public void json() throws Exception {
FreeStyleProject p = j.createFreeStyleProject("p");
JenkinsRule.WebClient wc = j.createWebClient();
assertEquals("{\"name\":\"p\"}", wc.goTo(p.getUrl() + "api/json?tree=name", "application/json").getWebResponse().getContentAsString());
assertEquals("wrap({\"name\":\"p\"})", wc.goTo(p.getUrl() + "api/json?tree=name&jsonp=wrap", "application/javascript").getWebResponse().getContentAsString());
}
@Test
@Issue("JENKINS-3267")
public void wrappedZeroItems() throws Exception {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册