Skip to content
Permalink
Browse files

[JENKINS-50590] do not remove all request parameters when adding a crumb

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 100cc61aa3d066f7762a5f642638ed495a36108d
Showing with 5 additions and 3 deletions.
  1. +5 −3 src/main/java/org/jvnet/hudson/test/JenkinsRule.java
@@ -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);
@@ -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);
}

/**

0 comments on commit 100cc61

Please sign in to comment.
You can’t perform that action at this time.