Skip to content

Commit

Permalink
[JENKINS-27607] Noting merge of #1623.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Mar 26, 2015
2 parents e54b19d + 5c6a098 commit bd4d157
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -55,6 +55,9 @@
<!-- 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>)
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/model/Api.java
Expand Up @@ -208,7 +208,7 @@ public void doSchema(StaplerRequest req, StaplerResponse rsp) throws IOException
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");
}
Expand Down
8 changes: 8 additions & 0 deletions test/src/test/java/hudson/model/ApiTest.java
Expand Up @@ -49,6 +49,14 @@ public void xpath() throws Exception {
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 {
Expand Down

0 comments on commit bd4d157

Please sign in to comment.