Skip to content

raw: URL encode the links to raw view of files #1383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/java/com/gitblit/servlet/RawServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import javax.servlet.http.HttpServletResponse;

import org.apache.tika.Tika;
import org.apache.wicket.protocol.http.WicketURLEncoder;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.MutableObjectId;
import org.eclipse.jgit.lib.ObjectLoader;
Expand Down Expand Up @@ -121,7 +122,8 @@ public static String asLink(String baseURL, String repository, String branch, St
path = path.substring(1);
}
String encodedPath = path == null ? "" : path.replace('/', fsc);
return baseURL + Constants.RAW_PATH + repository + "/" + (branch == null ? "" : (branch + "/" + encodedPath));
String fullPath = repository + "/" + (branch == null ? "" : (branch + "/" + encodedPath));
return baseURL + Constants.RAW_PATH + WicketURLEncoder.FULL_PATH_INSTANCE.encode(fullPath);
}


Expand Down