Skip to content

Commit

Permalink
Fixed an off-by-one error in calculating if the last element of a req…
Browse files Browse the repository at this point in the history
…uest was a /
  • Loading branch information
dpp committed Sep 23, 2011
1 parent 1cc2a43 commit b1ed911
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
13 changes: 11 additions & 2 deletions web/webkit/src/main/scala/net/liftweb/http/Req.scala
Expand Up @@ -338,7 +338,16 @@ object FileParamHolder {
}
}

private[http] object CurrentReq extends ThreadGlobal[Req]
/**
* A Thread-global containing the current Req. Set very, very early
*/
object CurrentReq extends ThreadGlobal[Req]

/**
* A ThreadGlobal containing the low-level HTTPRequest and HTTPResponse instances
* Set very, very early.
*/
object CurrentHTTPReqResp extends ThreadGlobal[(HTTPRequest, HTTPResponse)]

private final case class AvoidGAL(func: () => ParamCalcInfo) {
lazy val thunk: ParamCalcInfo = func()
Expand Down Expand Up @@ -520,7 +529,7 @@ object Req {
def parsePath(in: String): ParsePath = {
val p1 = fixURI((in match {case null => "/"; case s if s.length == 0 => "/"; case s => s}).replaceAll("/+", "/"))
val front = p1.startsWith("/")
val back = p1.length > 1 && p1.endsWith("/")
val back = p1.length >= 1 && p1.endsWith("/")

val orgLst = p1.replaceAll("/$", "/index").split("/").
toList.map(_.trim).filter(_.length > 0)
Expand Down
Expand Up @@ -57,21 +57,23 @@ trait HTTPProvider {
LiftRules.early.toList.foreach(_(req))
}

val newReq = Req(req, LiftRules.statelessRewrite.toList,
LiftRules.statelessTest.toList,
LiftRules.statelessReqTest.toList,
System.nanoTime)

CurrentReq.doWith(newReq) {
URLRewriter.doWith(url =>
NamedPF.applyBox(resp.encodeUrl(url),
LiftRules.urlDecorate.toList) openOr
resp.encodeUrl(url)) {
if (!(isLiftRequest_?(newReq) &&
actualServlet.service(newReq, resp))) {
chain
}
}
CurrentHTTPReqResp.doWith(req -> resp) {
val newReq = Req(req, LiftRules.statelessRewrite.toList,
LiftRules.statelessTest.toList,
LiftRules.statelessReqTest.toList,
System.nanoTime)

CurrentReq.doWith(newReq) {
URLRewriter.doWith(url =>
NamedPF.applyBox(resp.encodeUrl(url),
LiftRules.urlDecorate.toList) openOr
resp.encodeUrl(url)) {
if (!(isLiftRequest_?(newReq) &&
actualServlet.service(newReq, resp))) {
chain
}
}
}
}
}

Expand Down

0 comments on commit b1ed911

Please sign in to comment.