Skip to content

Commit 977e724

Browse files
authored
Merge pull request #1383 from flaix/encode-raw-links
raw: URL encode the links to raw view of files
2 parents 583e15e + f1b150b commit 977e724

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/java/com/gitblit/servlet/RawServlet.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import javax.servlet.http.HttpServletResponse;
3737

3838
import org.apache.tika.Tika;
39+
import org.apache.wicket.protocol.http.WicketURLEncoder;
3940
import org.eclipse.jgit.lib.FileMode;
4041
import org.eclipse.jgit.lib.MutableObjectId;
4142
import org.eclipse.jgit.lib.ObjectLoader;
@@ -121,7 +122,8 @@ public static String asLink(String baseURL, String repository, String branch, St
121122
path = path.substring(1);
122123
}
123124
String encodedPath = path == null ? "" : path.replace('/', fsc);
124-
return baseURL + Constants.RAW_PATH + repository + "/" + (branch == null ? "" : (branch + "/" + encodedPath));
125+
String fullPath = repository + "/" + (branch == null ? "" : (branch + "/" + encodedPath));
126+
return baseURL + Constants.RAW_PATH + WicketURLEncoder.FULL_PATH_INSTANCE.encode(fullPath);
125127
}
126128

127129

0 commit comments

Comments
 (0)