Skip to content

Commit

Permalink
[JENKINS-41121] Forgot to escape the escape character itself (and for…
Browse files Browse the repository at this point in the history
…got some files too)
  • Loading branch information
stephenc committed Jan 18, 2017
1 parent 1d254fa commit 4923bd1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
Expand Up @@ -205,7 +205,7 @@ public static abstract class BySCMSourceCriteria extends MultiBranchProjectFacto
* @param source a repository
* @return criteria for treating its branches as a match
*/
@NonNull
@CheckForNull
protected abstract SCMSourceCriteria getSCMSourceCriteria(@NonNull SCMSource source);

/**
Expand Down
18 changes: 12 additions & 6 deletions src/main/java/jenkins/branch/NameEncoder.java
Expand Up @@ -91,18 +91,21 @@ public static String encode(String name) {
In other words "/" / "?" / "#" / "[" / "]" everything else is going to be encoded for us anyway.
Note for safety, we will also encode "\" as some browsers convert that to a "/" so we want it double encoded
on the browser url.
on the browser url. And finally we need to escape our escape character "%"
*/
switch (c) {
case '#':
buf.append("%23");
break;
case '%':
buf.append("%25");
break;
case '/':
buf.append("%2F");
break;
case '?':
buf.append("%3F");
break;
case '#':
buf.append("%23");
break;
buf.append("%3F");
break;
case '[':
buf.append("%5B");
break;
Expand Down Expand Up @@ -155,6 +158,9 @@ public static String decode(String name) {
case '3':
buf.append('#');
break;
case '5':
buf.append('%');
break;
case 'F':
buf.append('/');
break;
Expand Down
Expand Up @@ -25,6 +25,7 @@

package integration.harness;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.model.ItemGroup;
Expand All @@ -46,7 +47,7 @@ public BasicMultiBranchProjectFactory(SCMSourceCriteria criteria) {
this.criteria = criteria;
}

@NonNull
@CheckForNull
@Override
protected SCMSourceCriteria getSCMSourceCriteria(@NonNull SCMSource source) {
return criteria;
Expand Down

0 comments on commit 4923bd1

Please sign in to comment.