Skip to content

Commit

Permalink
[JENKINS-50590] do not remove all request parameters when adding a crumb
Browse files Browse the repository at this point in the history
Handle the crumb in a query string as well as a Form.
No longer checks existing parameters are empty as addAll will do that.
  • Loading branch information
jtnord committed Apr 9, 2018
1 parent 4821d0f commit 100cc61
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/java/org/jvnet/hudson/test/JenkinsRule.java
Expand Up @@ -2303,7 +2303,7 @@ public WebRequest addCrumb(WebRequest req) {
ArrayList<NameValuePair> params = new ArrayList<>();
params.add(getCrumbHeaderNVP());
List<NameValuePair> oldParams = req.getRequestParameters();
if (oldParams != null && !oldParams.isEmpty()) {
if (oldParams != null) {
params.addAll(oldParams);
}
req.setRequestParameters(params);
Expand All @@ -2317,8 +2317,10 @@ public URL createCrumbedUrl(String relativePath) throws IOException {
CrumbIssuer issuer = jenkins.getCrumbIssuer();
String crumbName = issuer.getDescriptor().getCrumbRequestField();
String crumb = issuer.getCrumb(null);

return new URL(getContextPath()+relativePath+"?"+crumbName+"="+crumb);
if (relativePath.indexOf('?') == -1) {
return new URL(getContextPath()+relativePath+"?"+crumbName+"="+crumb);
}
return new URL(getContextPath()+relativePath+"&"+crumbName+"="+crumb);
}

/**
Expand Down

0 comments on commit 100cc61

Please sign in to comment.