diff --git a/src/main/java/hudson/plugins/git/browser/BitbucketServer.java b/src/main/java/hudson/plugins/git/browser/BitbucketServer.java index 11c0cbbe4a..efe5c6f424 100644 --- a/src/main/java/hudson/plugins/git/browser/BitbucketServer.java +++ b/src/main/java/hudson/plugins/git/browser/BitbucketServer.java @@ -5,6 +5,7 @@ import hudson.plugins.git.GitChangeSet; import hudson.scm.EditType; import hudson.scm.RepositoryBrowser; +import hudson.Util; import net.sf.json.JSONObject; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -55,7 +56,7 @@ public URL getDiffLink(GitChangeSet.Path path) throws IOException { private URL getDiffLinkRegardlessOfEditType(GitChangeSet.Path path) throws IOException { final GitChangeSet changeSet = path.getChangeSet(); final String pathAsString = path.getPath(); - return new URL(getChangeSetLink(changeSet), "#" + pathAsString); + return new URL(getChangeSetLink(changeSet), "#" + Util.rawEncode(pathAsString)); } /** @@ -69,7 +70,7 @@ private URL getDiffLinkRegardlessOfEditType(GitChangeSet.Path path) throws IOExc public URL getFileLink(GitChangeSet.Path path) throws IOException { final String pathAsString = path.getPath(); URL url = getUrl(); - return encodeURL(new URL(url, url.getPath() + "browse/" + pathAsString)); + return encodeURL(new URL(url, url.getPath() + "browse/" + Util.rawEncode(pathAsString))); } @Extension @Symbol("bitbucketServer") diff --git a/src/main/java/hudson/plugins/git/browser/BitbucketWeb.java b/src/main/java/hudson/plugins/git/browser/BitbucketWeb.java index d7d288e87f..2ba5dceccd 100644 --- a/src/main/java/hudson/plugins/git/browser/BitbucketWeb.java +++ b/src/main/java/hudson/plugins/git/browser/BitbucketWeb.java @@ -5,6 +5,7 @@ import hudson.plugins.git.GitChangeSet; import hudson.scm.EditType; import hudson.scm.RepositoryBrowser; +import hudson.Util; import net.sf.json.JSONObject; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -55,7 +56,7 @@ public URL getDiffLink(GitChangeSet.Path path) throws IOException { private URL getDiffLinkRegardlessOfEditType(GitChangeSet.Path path) throws IOException { final GitChangeSet changeSet = path.getChangeSet(); final String pathAsString = path.getPath(); - return new URL(getChangeSetLink(changeSet), "#chg-" + pathAsString); + return new URL(getChangeSetLink(changeSet), "#chg-" + Util.rawEncode(pathAsString)); } /** @@ -69,7 +70,7 @@ private URL getDiffLinkRegardlessOfEditType(GitChangeSet.Path path) throws IOExc public URL getFileLink(GitChangeSet.Path path) throws IOException { final String pathAsString = path.getPath(); URL url = getUrl(); - return encodeURL(new URL(url, url.getPath() + "history/" + pathAsString)); + return encodeURL(new URL(url, url.getPath() + "history/" + Util.rawEncode(pathAsString))); } @Extension diff --git a/src/main/java/hudson/plugins/git/browser/GitLab.java b/src/main/java/hudson/plugins/git/browser/GitLab.java index 48562c710e..6956b18351 100644 --- a/src/main/java/hudson/plugins/git/browser/GitLab.java +++ b/src/main/java/hudson/plugins/git/browser/GitLab.java @@ -6,6 +6,7 @@ import hudson.plugins.git.GitChangeSet.Path; import hudson.scm.EditType; import hudson.scm.RepositoryBrowser; +import hudson.Util; import hudson.util.FormValidation; import net.sf.json.JSONObject; @@ -103,7 +104,7 @@ public URL getDiffLink(Path path) throws IOException { final GitChangeSet changeSet = path.getChangeSet(); String filelink; if (getVersionDouble() < 8.0) { - filelink = "#" + path.getPath(); + filelink = "#" + Util.rawEncode(path.getPath()); } else { filelink = "#diff-" + getIndexOfPath(path); } @@ -126,11 +127,11 @@ public URL getFileLink(Path path) throws IOException { return getDiffLink(path); } else { if (getVersionDouble() <= 4.2) { - return encodeURL(new URL(getUrl(), "tree/" + path.getChangeSet().getId() + "/" + path.getPath())); + return encodeURL(new URL(getUrl(), "tree/" + path.getChangeSet().getId() + "/" + Util.rawEncode(path.getPath()))); } else if (getVersionDouble() < 5.1) { - return encodeURL(new URL(getUrl(), path.getChangeSet().getId() + "/tree/" + path.getPath())); + return encodeURL(new URL(getUrl(), path.getChangeSet().getId() + "/tree/" + Util.rawEncode(path.getPath()))); } else { - return encodeURL(new URL(getUrl(), "blob/" + path.getChangeSet().getId() + "/" + path.getPath())); + return encodeURL(new URL(getUrl(), "blob/" + path.getChangeSet().getId() + "/" + Util.rawEncode(path.getPath()))); } } } diff --git a/src/main/java/hudson/plugins/git/browser/GitWeb.java b/src/main/java/hudson/plugins/git/browser/GitWeb.java index 7b6f37c702..ca0f4481c2 100644 --- a/src/main/java/hudson/plugins/git/browser/GitWeb.java +++ b/src/main/java/hudson/plugins/git/browser/GitWeb.java @@ -7,6 +7,7 @@ import hudson.scm.EditType; import hudson.scm.RepositoryBrowser; import hudson.scm.browsers.QueryBuilder; +import hudson.Util; import net.sf.json.JSONObject; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -62,7 +63,7 @@ public URL getDiffLink(Path path) throws IOException { } GitChangeSet changeSet = path.getChangeSet(); URL url = getUrl(); - String spec = param(url).add("a=blobdiff").add("f=" + path.getPath()).add("fp=" + path.getPath()) + String spec = param(url).add("a=blobdiff").add("f=" + Util.rawEncode(path.getPath())).add("fp=" + Util.rawEncode(path.getPath())) .add("h=" + path.getSrc()).add("hp=" + path.getDst()) .add("hb=" + changeSet.getId()).add("hpb=" + changeSet.getParentCommit()).toString(); return new URL(url, url.getPath()+spec); @@ -79,7 +80,7 @@ public URL getDiffLink(Path path) throws IOException { public URL getFileLink(Path path) throws IOException { URL url = getUrl(); String h = (path.getDst() != null) ? path.getDst() : path.getSrc(); - String spec = param(url).add("a=blob").add("f=" + path.getPath()) + String spec = param(url).add("a=blob").add("f=" + Util.rawEncode(path.getPath())) .add("h=" + h).add("hb=" + path.getChangeSet().getId()).toString(); return encodeURL(new URL(url, url.getPath()+spec)); } diff --git a/src/main/java/hudson/plugins/git/browser/GithubWeb.java b/src/main/java/hudson/plugins/git/browser/GithubWeb.java index 133aca461a..53724260b2 100644 --- a/src/main/java/hudson/plugins/git/browser/GithubWeb.java +++ b/src/main/java/hudson/plugins/git/browser/GithubWeb.java @@ -6,6 +6,7 @@ import hudson.plugins.git.GitChangeSet.Path; import hudson.scm.EditType; import hudson.scm.RepositoryBrowser; +import hudson.Util; import net.sf.json.JSONObject; import org.jenkinsci.Symbol; @@ -80,7 +81,7 @@ public URL getFileLink(Path path) throws IOException { if (path.getEditType().equals(EditType.DELETE)) { return getDiffLinkRegardlessOfEditType(path); } else { - final String spec = "blob/" + path.getChangeSet().getId() + "/" + path.getPath(); + final String spec = "blob/" + path.getChangeSet().getId() + "/" + Util.rawEncode(path.getPath()); return encodeURL(buildURL(spec)); } } diff --git a/src/test/java/hudson/plugins/git/browser/BitbucketServerTest.java b/src/test/java/hudson/plugins/git/browser/BitbucketServerTest.java index bbfad4818e..91855ce6fd 100644 --- a/src/test/java/hudson/plugins/git/browser/BitbucketServerTest.java +++ b/src/test/java/hudson/plugins/git/browser/BitbucketServerTest.java @@ -29,6 +29,10 @@ public class BitbucketServerTest { private static final String BITBUCKET_URL = "http://bitbucket-server:7990/USER/REPO"; private final BitbucketServer bitbucketServer = new BitbucketServer(BITBUCKET_URL); + private final String path1StrEncoded = "src%2Fmain%2Fjava%2Fhudson%2Fplugins%2Fgit%2Fbrowser%2FGithubWeb.java"; + private final String path1StrEncodedPath = "src%252Fmain%252Fjava%252Fhudson%252Fplugins%252Fgit%252Fbrowser%252FGithubWeb.java"; + private final String path2StrEncoded = "src%2Ftest%2Fjava%2Fhudson%2Fplugins%2Fgit%2Fbrowser%2FGithubWebTest.java"; + @Test public void testGetUrl() throws IOException { assertEquals(String.valueOf(bitbucketServer.getUrl()), BITBUCKET_URL + "/"); @@ -51,11 +55,11 @@ public void testGetDiffLinkPath() throws Exception { final String path1Str = "src/main/java/hudson/plugins/git/browser/GithubWeb.java"; final Path path1 = pathMap.get(path1Str); - assertEquals(BITBUCKET_URL + "/commits/396fc230a3db05c427737aa5c2eb7856ba72b05d#" + path1Str, bitbucketServer.getDiffLink(path1).toString()); - + assertEquals(BITBUCKET_URL + "/commits/396fc230a3db05c427737aa5c2eb7856ba72b05d#" + path1StrEncoded, bitbucketServer.getDiffLink(path1).toString()); + final String path2Str = "src/test/java/hudson/plugins/git/browser/GithubWebTest.java"; final Path path2 = pathMap.get(path2Str); - assertEquals(BITBUCKET_URL + "/commits/396fc230a3db05c427737aa5c2eb7856ba72b05d#" + path2Str, bitbucketServer.getDiffLink(path2).toString()); + assertEquals(BITBUCKET_URL + "/commits/396fc230a3db05c427737aa5c2eb7856ba72b05d#" + path2StrEncoded, bitbucketServer.getDiffLink(path2).toString()); final String path3Str = "src/test/resources/hudson/plugins/git/browser/rawchangelog-with-deleted-file"; final Path path3 = pathMap.get(path3Str); assertNull("Do not return a diff link for added files.", bitbucketServer.getDiffLink(path3)); @@ -66,7 +70,7 @@ public void testGetFileLinkPath() throws Exception { final HashMap pathMap = createPathMap("rawchangelog"); final Path path = pathMap.get("src/main/java/hudson/plugins/git/browser/GithubWeb.java"); final URL fileLink = bitbucketServer.getFileLink(path); - assertEquals(BITBUCKET_URL + "/browse/src/main/java/hudson/plugins/git/browser/GithubWeb.java", String.valueOf(fileLink)); + assertEquals(BITBUCKET_URL + "/browse/" + path1StrEncodedPath, String.valueOf(fileLink)); } @Test diff --git a/src/test/java/hudson/plugins/git/browser/BitbucketWebTest.java b/src/test/java/hudson/plugins/git/browser/BitbucketWebTest.java index 130924f9b1..fb9ddf04bb 100644 --- a/src/test/java/hudson/plugins/git/browser/BitbucketWebTest.java +++ b/src/test/java/hudson/plugins/git/browser/BitbucketWebTest.java @@ -30,6 +30,10 @@ public class BitbucketWebTest { private static final String BITBUCKET_URL = "http://bitbucket.org/USER/REPO"; private final BitbucketWeb bitbucketWeb = new BitbucketWeb(BITBUCKET_URL); + private final String path1StrEncoded = "src%2Fmain%2Fjava%2Fhudson%2Fplugins%2Fgit%2Fbrowser%2FGithubWeb.java"; + private final String path1StrEncodedPath = "src%252Fmain%252Fjava%252Fhudson%252Fplugins%252Fgit%252Fbrowser%252FGithubWeb.java"; + private final String path2StrEncoded = "src%2Ftest%2Fjava%2Fhudson%2Fplugins%2Fgit%2Fbrowser%2FGithubWebTest.java"; + @Test public void testGetUrl() throws IOException { assertEquals(String.valueOf(bitbucketWeb.getUrl()), BITBUCKET_URL + "/"); @@ -52,11 +56,11 @@ public void testGetDiffLinkPath() throws Exception { final String path1Str = "src/main/java/hudson/plugins/git/browser/GithubWeb.java"; final Path path1 = pathMap.get(path1Str); - assertEquals(BITBUCKET_URL + "/commits/396fc230a3db05c427737aa5c2eb7856ba72b05d#chg-" + path1Str, bitbucketWeb.getDiffLink(path1).toString()); + assertEquals(BITBUCKET_URL + "/commits/396fc230a3db05c427737aa5c2eb7856ba72b05d#chg-" + path1StrEncoded, bitbucketWeb.getDiffLink(path1).toString()); final String path2Str = "src/test/java/hudson/plugins/git/browser/GithubWebTest.java"; final Path path2 = pathMap.get(path2Str); - assertEquals(BITBUCKET_URL + "/commits/396fc230a3db05c427737aa5c2eb7856ba72b05d#chg-" + path2Str, bitbucketWeb.getDiffLink(path2).toString()); + assertEquals(BITBUCKET_URL + "/commits/396fc230a3db05c427737aa5c2eb7856ba72b05d#chg-" + path2StrEncoded, bitbucketWeb.getDiffLink(path2).toString()); final String path3Str = "src/test/resources/hudson/plugins/git/browser/rawchangelog-with-deleted-file"; final Path path3 = pathMap.get(path3Str); assertNull("Do not return a diff link for added files.", bitbucketWeb.getDiffLink(path3)); @@ -67,7 +71,7 @@ public void testGetFileLinkPath() throws Exception { final HashMap pathMap = createPathMap("rawchangelog"); final Path path = pathMap.get("src/main/java/hudson/plugins/git/browser/GithubWeb.java"); final URL fileLink = bitbucketWeb.getFileLink(path); - assertEquals(BITBUCKET_URL + "/history/src/main/java/hudson/plugins/git/browser/GithubWeb.java", String.valueOf(fileLink)); + assertEquals(BITBUCKET_URL + "/history/" + path1StrEncodedPath, String.valueOf(fileLink)); } @Test diff --git a/src/test/java/hudson/plugins/git/browser/GitLabTest.java b/src/test/java/hudson/plugins/git/browser/GitLabTest.java index f5880e736d..7946efc982 100644 --- a/src/test/java/hudson/plugins/git/browser/GitLabTest.java +++ b/src/test/java/hudson/plugins/git/browser/GitLabTest.java @@ -38,6 +38,8 @@ public class GitLabTest { private final String SHA1 = "396fc230a3db05c427737aa5c2eb7856ba72b05d"; private final String fileName = "src/main/java/hudson/plugins/git/browser/GithubWeb.java"; + private final String encodedFileNameFragment = "src%2Fmain%2Fjava%2Fhudson%2Fplugins%2Fgit%2Fbrowser%2FGithubWeb.java"; + private final String encodedFileNamePath = "src%252Fmain%252Fjava%252Fhudson%252Fplugins%252Fgit%252Fbrowser%252FGithubWeb.java"; @Test public void testGetVersion() { @@ -88,8 +90,8 @@ public void testGetChangeSetLinkGitChangeSet() throws Exception { public void testGetDiffLinkPath() throws Exception { final HashMap pathMap = createPathMap("rawchangelog"); final Path modified1 = pathMap.get(fileName); - final String expectedPre30 = GITLAB_URL + "commits/" + SHA1 + "#" + fileName; - final String expectedPre80 = GITLAB_URL + "commit/" + SHA1 + "#" + fileName; + final String expectedPre30 = GITLAB_URL + "commits/" + SHA1 + "#" + encodedFileNameFragment; + final String expectedPre80 = GITLAB_URL + "commit/" + SHA1 + "#" + encodedFileNameFragment; final String expectedURL = GITLAB_URL + "commit/" + SHA1 + "#" + "diff-0"; final String expectedDefault = expectedURL; assertEquals(expectedPre30, gitlabNegative.getDiffLink(modified1).toString()); @@ -111,9 +113,9 @@ public void testGetDiffLinkPath() throws Exception { public void testGetFileLinkPath() throws Exception { final HashMap pathMap = createPathMap("rawchangelog"); final Path path = pathMap.get(fileName); - final String expectedURL = GITLAB_URL + "blob/396fc230a3db05c427737aa5c2eb7856ba72b05d/" + fileName; + final String expectedURL = GITLAB_URL + "blob/396fc230a3db05c427737aa5c2eb7856ba72b05d/" + encodedFileNamePath; final String expectedV29 = expectedURL.replace("blob/", "tree/"); - final String expectedV50 = GITLAB_URL + "396fc230a3db05c427737aa5c2eb7856ba72b05d/tree/" + fileName; + final String expectedV50 = GITLAB_URL + "396fc230a3db05c427737aa5c2eb7856ba72b05d/tree/" + encodedFileNamePath; assertEquals(expectedV29, gitlabNegative.getFileLink(path).toString()); assertEquals(expectedV29, gitlab29.getFileLink(path).toString()); assertEquals(expectedV29, gitlab42.getFileLink(path).toString()); diff --git a/src/test/java/hudson/plugins/git/browser/GitWebTest.java b/src/test/java/hudson/plugins/git/browser/GitWebTest.java index 615868a630..3bce13b159 100644 --- a/src/test/java/hudson/plugins/git/browser/GitWebTest.java +++ b/src/test/java/hudson/plugins/git/browser/GitWebTest.java @@ -24,6 +24,9 @@ public class GitWebTest { private static final String GITWEB_URL = "https://SERVER/gitweb?repo.git"; private final GitWeb gitwebWeb = new GitWeb(GITWEB_URL); + private final String encodedFileNameQuery = "src%2Fmain%2Fjava%2Fhudson%2Fplugins%2Fgit%2Fbrowser%2FGithubWeb.java"; + private final String encodedFileNameQueryDouble = "src%252Fmain%252Fjava%252Fhudson%252Fplugins%252Fgit%252Fbrowser%252FGithubWeb.java"; + @Test public void testGetUrl() throws IOException { assertEquals(String.valueOf(gitwebWeb.getUrl()), GITWEB_URL); @@ -39,7 +42,7 @@ public void testGetChangeSetLinkGitChangeSet() throws Exception { public void testGetDiffLinkPath() throws Exception { final HashMap pathMap = createPathMap("rawchangelog"); final Path modified1 = pathMap.get("src/main/java/hudson/plugins/git/browser/GithubWeb.java"); - assertEquals(GITWEB_URL + "&a=blobdiff&f=src/main/java/hudson/plugins/git/browser/GithubWeb.java&fp=src/main/java/hudson/plugins/git/browser/GithubWeb.java&h=3f28ad75f5ecd5e0ea9659362e2eef18951bd451&hp=2e0756cd853dccac638486d6aab0e74bc2ef4041&hb=396fc230a3db05c427737aa5c2eb7856ba72b05d&hpb=f28f125f4cc3e5f6a32daee6a26f36f7b788b8ff", gitwebWeb.getDiffLink(modified1).toString()); + assertEquals(GITWEB_URL + "&a=blobdiff&f=" + encodedFileNameQuery + "&fp=" + encodedFileNameQuery + "&h=3f28ad75f5ecd5e0ea9659362e2eef18951bd451&hp=2e0756cd853dccac638486d6aab0e74bc2ef4041&hb=396fc230a3db05c427737aa5c2eb7856ba72b05d&hpb=f28f125f4cc3e5f6a32daee6a26f36f7b788b8ff", gitwebWeb.getDiffLink(modified1).toString()); } @Test @@ -47,7 +50,7 @@ public void testGetFileLinkPath() throws Exception { final HashMap pathMap = createPathMap("rawchangelog"); final Path path = pathMap.get("src/main/java/hudson/plugins/git/browser/GithubWeb.java"); final URL fileLink = gitwebWeb.getFileLink(path); - assertEquals(GITWEB_URL + "&a=blob&f=src/main/java/hudson/plugins/git/browser/GithubWeb.java&h=2e0756cd853dccac638486d6aab0e74bc2ef4041&hb=396fc230a3db05c427737aa5c2eb7856ba72b05d", String.valueOf(fileLink)); + assertEquals(GITWEB_URL + "&a=blob&f=" + encodedFileNameQueryDouble + "&h=2e0756cd853dccac638486d6aab0e74bc2ef4041&hb=396fc230a3db05c427737aa5c2eb7856ba72b05d", String.valueOf(fileLink)); } @Test diff --git a/src/test/java/hudson/plugins/git/browser/GithubWebTest.java b/src/test/java/hudson/plugins/git/browser/GithubWebTest.java index 13b6810e58..c0329674e7 100644 --- a/src/test/java/hudson/plugins/git/browser/GithubWebTest.java +++ b/src/test/java/hudson/plugins/git/browser/GithubWebTest.java @@ -76,16 +76,15 @@ public void testGetFileLinkPath() throws Exception { final HashMap pathMap = createPathMap("rawchangelog"); final Path path = pathMap.get("src/main/java/hudson/plugins/git/browser/GithubWeb.java"); final URL fileLink = githubWeb.getFileLink(path); - assertEquals(GITHUB_URL + "/blob/396fc230a3db05c427737aa5c2eb7856ba72b05d/src/main/java/hudson/plugins/git/browser/GithubWeb.java", String.valueOf(fileLink)); + assertEquals(GITHUB_URL + "/blob/396fc230a3db05c427737aa5c2eb7856ba72b05d/src%252Fmain%252Fjava%252Fhudson%252Fplugins%252Fgit%252Fbrowser%252FGithubWeb.java", String.valueOf(fileLink)); } - @Issue("JENKINS-42597") @Test public void testGetFileLinkPathWithEscape() throws Exception { final HashMap pathMap = createPathMap("rawchangelog-with-escape"); final Path path = pathMap.get("src/test/java/hudson/plugins/git/browser/conf%.txt"); final URL fileLink = githubWeb.getFileLink(path); - assertEquals(GITHUB_URL + "/blob/396fc230a3db05c427737aa5c2eb7856ba72b05d/src/test/java/hudson/plugins/git/browser/conf%25.txt", String.valueOf(fileLink)); + assertEquals(GITHUB_URL + "/blob/396fc230a3db05c427737aa5c2eb7856ba72b05d/src%252Ftest%252Fjava%252Fhudson%252Fplugins%252Fgit%252Fbrowser%252Fconf%2525.txt", String.valueOf(fileLink)); } @Issue("JENKINS-42597") @Test @@ -93,7 +92,7 @@ public void testGetFileLinkPathWithWindowsUnescapeChar() throws Exception { final HashMap pathMap = createPathMap("rawchangelog-with-escape"); final Path path = pathMap.get("src/test/java/hudson/plugins/git/browser/conf^%.txt"); final URL fileLink = githubWeb.getFileLink(path); - assertEquals(GITHUB_URL + "/blob/396fc230a3db05c427737aa5c2eb7856ba72b05d/src/test/java/hudson/plugins/git/browser/conf%5E%25.txt", String.valueOf(fileLink)); + assertEquals(GITHUB_URL + "/blob/396fc230a3db05c427737aa5c2eb7856ba72b05d/src%252Ftest%252Fjava%252Fhudson%252Fplugins%252Fgit%252Fbrowser%252Fconf%255E%2525.txt", String.valueOf(fileLink)); } @Issue("JENKINS-42597") @@ -102,7 +101,7 @@ public void testGetFileLinkPathWithDoubleEscape() throws Exception { final HashMap pathMap = createPathMap("rawchangelog-with-escape"); final Path path = pathMap.get("src/test/java/hudson/plugins/git/browser/conf%%.txt"); final URL fileLink = githubWeb.getFileLink(path); - assertEquals(GITHUB_URL + "/blob/396fc230a3db05c427737aa5c2eb7856ba72b05d/src/test/java/hudson/plugins/git/browser/conf%25%25.txt", String.valueOf(fileLink)); + assertEquals(GITHUB_URL + "/blob/396fc230a3db05c427737aa5c2eb7856ba72b05d/src%252Ftest%252Fjava%252Fhudson%252Fplugins%252Fgit%252Fbrowser%252Fconf%2525%2525.txt", String.valueOf(fileLink)); } @Issue("JENKINS-42597") @@ -111,7 +110,7 @@ public void testGetFileLinkPathWithWindowsEnvironmentalVariable() throws Excepti final HashMap pathMap = createPathMap("rawchangelog-with-escape"); final Path path = pathMap.get("src/test/java/hudson/plugins/git/browser/conf%abc%.txt"); final URL fileLink = githubWeb.getFileLink(path); - assertEquals(GITHUB_URL + "/blob/396fc230a3db05c427737aa5c2eb7856ba72b05d/src/test/java/hudson/plugins/git/browser/conf%25abc%25.txt", String.valueOf(fileLink)); + assertEquals(GITHUB_URL + "/blob/396fc230a3db05c427737aa5c2eb7856ba72b05d/src%252Ftest%252Fjava%252Fhudson%252Fplugins%252Fgit%252Fbrowser%252Fconf%2525abc%2525.txt", String.valueOf(fileLink)); } @Issue("JENKINS-42597") @@ -120,7 +119,7 @@ public void testGetFileLinkPathWithSpaceInName() throws Exception { final HashMap pathMap = createPathMap("rawchangelog-with-escape"); final Path path = pathMap.get("src/test/java/hudson/plugins/git/browser/config file.txt"); final URL fileLink = githubWeb.getFileLink(path); - assertEquals(GITHUB_URL + "/blob/396fc230a3db05c427737aa5c2eb7856ba72b05d/src/test/java/hudson/plugins/git/browser/config%20file.txt", String.valueOf(fileLink)); + assertEquals(GITHUB_URL + "/blob/396fc230a3db05c427737aa5c2eb7856ba72b05d/src%252Ftest%252Fjava%252Fhudson%252Fplugins%252Fgit%252Fbrowser%252Fconfig%2520file.txt", String.valueOf(fileLink)); } @Test