diff options
author | Florian Zschocke <f.zschocke+git@gmail.com> | 2020-11-09 23:08:22 +0100 |
---|---|---|
committer | Florian Zschocke <f.zschocke+git@gmail.com> | 2020-11-10 00:05:07 +0100 |
commit | 6876537c856dda897f081430bb11b394f8b291bb (patch) | |
tree | b587da62023fcde2e6d905ea019a38f9f9fafd1e /src/test/java | |
parent | 3212dc014c445425cc09f8d92065f1afb4e53065 (diff) | |
download | gitblit-6876537c856dda897f081430bb11b394f8b291bb.tar.gz gitblit-6876537c856dda897f081430bb11b394f8b291bb.zip |
raw: Fix raw links to branches with a slash in their name
When a branch has a slash in the name, the raw servlet was not able
to find the path under that branch. This is due to the replacement of
the forward slash character for URLs. It was not taken into account
when comparing the branch name later.
This fixes #1290 and its duplicates #1234 and #813.
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/com/gitblit/servlet/RawServletTest.java | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/test/java/com/gitblit/servlet/RawServletTest.java b/src/test/java/com/gitblit/servlet/RawServletTest.java index dac9896e..50587178 100644 --- a/src/test/java/com/gitblit/servlet/RawServletTest.java +++ b/src/test/java/com/gitblit/servlet/RawServletTest.java @@ -17,7 +17,7 @@ import static org.mockito.Mockito.mock; public class RawServletTest { - private static final String FSC = "!"; + private static final char FSC = RawServlet.FSC; private static MockRuntimeManager mockRuntimeManager = new MockRuntimeManager(); private static IStoredSettings settings; @@ -170,7 +170,7 @@ public class RawServletTest String link = RawServlet.asLink(baseUrl, repository, branch, path); assertNotNull(link); - assertEquals(baseUrl + Constants.RAW_PATH + repository + "/" + branch.replaceAll("/", FSC) + "/", link); + assertEquals(baseUrl + Constants.RAW_PATH + repository + "/" + branch.replace('/', FSC) + "/", link); } @Test @@ -185,7 +185,7 @@ public class RawServletTest assertNotNull(link); assertEquals(baseUrl.substring(0, baseUrl.length()-1) + Constants.RAW_PATH + repository + "/" - + branch.replaceAll("/", FSC) + "/", link); + + branch.replace('/', FSC) + "/", link); } @Test @@ -200,7 +200,7 @@ public class RawServletTest assertNotNull(link); assertEquals(baseUrl + Constants.RAW_PATH + repository.substring(1) + "/" - + branch.replaceAll("/", FSC) + "/", link); + + branch.replace('/', FSC) + "/", link); } @Test @@ -215,7 +215,7 @@ public class RawServletTest assertNotNull(link); assertEquals(baseUrl.substring(0, baseUrl.length()-1) + Constants.RAW_PATH + repository.substring(1) + "/" - + branch.replaceAll("/", FSC) + "/", link); + + branch.replace('/', FSC) + "/", link); } @@ -245,7 +245,7 @@ public class RawServletTest assertNotNull(link); assertEquals(baseUrl.substring(0, baseUrl.length()-1) + Constants.RAW_PATH + repository + "/" - + branch + "/" + path.replaceAll("/", FSC), link); + + branch + "/" + path.replace('/', FSC), link); } @Test @@ -274,7 +274,7 @@ public class RawServletTest assertNotNull(link); assertEquals(baseUrl.substring(0, baseUrl.length()-1) + Constants.RAW_PATH + repository.substring(1) + "/" - + branch + "/" + path.replaceAll("/", FSC), link); + + branch + "/" + path.replace('/', FSC), link); } @@ -290,7 +290,7 @@ public class RawServletTest assertNotNull(link); assertEquals(baseUrl + Constants.RAW_PATH + repository + "/" - + branch.replaceAll("/", FSC) + "/" + path, link); + + branch.replace('/', FSC) + "/" + path, link); } @Test @@ -305,7 +305,7 @@ public class RawServletTest assertNotNull(link); assertEquals(baseUrl.substring(0, baseUrl.length()-1) + Constants.RAW_PATH + repository + "/" - + branch.replaceAll("/", FSC) + "/" + path.replaceAll("/", FSC), link); + + branch.replace('/', FSC) + "/" + path.replace('/', FSC), link); } @Test @@ -320,7 +320,7 @@ public class RawServletTest assertNotNull(link); assertEquals(baseUrl + Constants.RAW_PATH + repository.substring(1) + "/" - + branch.replaceAll("/", FSC) + "/" + path, link); + + branch.replace('/', FSC) + "/" + path, link); } @Test @@ -335,7 +335,7 @@ public class RawServletTest assertNotNull(link); assertEquals(baseUrl.substring(0, baseUrl.length()-1) + Constants.RAW_PATH + repository.substring(1) + "/" - + branch.replaceAll("/", FSC) + "/" + path.replaceAll("/", FSC), link); + + branch.replace('/', FSC) + "/" + path.replace('/', FSC), link); } @Test @@ -393,7 +393,7 @@ public class RawServletTest assertNotNull(link); assertEquals(baseUrl + Constants.RAW_PATH + repository + "/" - + branch.replaceAll("/", FSC) + "/", link); + + branch.replace('/', FSC) + "/", link); } @Test @@ -423,7 +423,7 @@ public class RawServletTest assertNotNull(link); assertEquals(baseUrl + Constants.RAW_PATH + repository.substring(1) + "/" - + branch.replaceAll("/", FSC) + "/" + path.replaceAll("/", FSC), link); + + branch.replace('/', FSC) + "/" + path.replace('/', FSC), link); } @Test @@ -541,7 +541,7 @@ public class RawServletTest assertNotNull(link); assertEquals(baseUrl + Constants.RAW_PATH + repository + "/" - + branch + "/" + path.replaceAll("/", FSC), link); + + branch + "/" + path.replace('/', FSC), link); } @Test @@ -1289,7 +1289,7 @@ public class RawServletTest @Test public void getPath_RepoBranchWithFsc_explicitFscSameAsDefault() { - settings.overrideSetting(Keys.web.forwardSlashCharacter, FSC); + settings.overrideSetting(Keys.web.forwardSlashCharacter, String.valueOf(FSC)); String path = rawServlet.getPath("git.git", "some/feature", "git.git/some" + FSC + "feature"); @@ -1309,7 +1309,7 @@ public class RawServletTest @Test public void getPath_LeadindRepoBranchWithFscFolderFile_explicitFscSameAsDefault() { - settings.overrideSetting(Keys.web.forwardSlashCharacter, FSC); + settings.overrideSetting(Keys.web.forwardSlashCharacter, String.valueOf(FSC)); String path = rawServlet.getPath("git.git", "some/feature", "IBM/git.git/some" + FSC + "feature/some" + FSC + "folder" + FSC + "file.dot"); |