Modify contextPath to the literal pattern

Because contextPath can contain some special chars.
This commit is contained in:
Mitsuhiro Koga
2016-07-26 20:47:27 +09:00
parent 485516be2e
commit 442c0d575e

View File

@@ -4,6 +4,8 @@ import gitbucket.core.api.JsonFormat
import gitbucket.core.controller.Context
import gitbucket.core.servlet.Database
import java.util.regex.Pattern.quote
import javax.servlet.http.{HttpSession, HttpServletRequest}
import scala.util.matching.Regex
@@ -73,7 +75,7 @@ object Implicits {
def hasAttribute(name: String): Boolean = request.getAttribute(name) != null
def gitRepositoryPath: String = request.getRequestURI.replaceFirst("^" + request.getContextPath + "/git/", "/")
def gitRepositoryPath: String = request.getRequestURI.replaceFirst("^" + quote(request.getContextPath) + "/git/", "/")
def baseUrl:String = {
val url = request.getRequestURL.toString