Skip to content
This repository has been archived by the owner on Jul 22, 2018. It is now read-only.

Commit

Permalink
Workaround for the JVM double parsing vulnerability
Browse files Browse the repository at this point in the history
  • Loading branch information
dpp committed Feb 1, 2011
1 parent 2ab684f commit 065ae99
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
Expand Up @@ -59,7 +59,7 @@ trait OAuthValidator {
for {
msg <- message
verParam <- msg.getParameter(OAuthUtil.OAUTH_VERSION)
version <- tryo(verParam.value.toDouble).filter(v => v < MIN_VERSION || MAX_VERSION < v) ?~
version <- tryo(ParseDouble(verParam.value)).filter(v => v < MIN_VERSION || MAX_VERSION < v) ?~
OAuthUtil.Problems.VERSION_REJECTED._1 ~> OAuthProblem(OAuthUtil.Problems.VERSION_REJECTED,
(OAuthUtil.ProblemParams.OAUTH_ACCEPTABLE_VERSIONS, MIN_VERSION + "-" + MAX_VERSION))
} yield msg
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2010 WorldWide Conferencing, LLC
* Copyright 2007-2011 WorldWide Conferencing, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,17 +14,18 @@
* limitations under the License.
*/

package net.liftweb {
package widgets {
package uploadprogress {
package net.liftweb
package widgets
package uploadprogress

import _root_.scala.xml.{NodeSeq,Text}
import _root_.net.liftweb.http.{SessionVar,Req,GetRequest,PlainTextResponse,JsonResponse,
import scala.xml.{NodeSeq,Text}
import net.liftweb.http.{SessionVar,Req,GetRequest,PlainTextResponse,JsonResponse,
LiftRules,OnDiskFileParamHolder,S,ResourceServer,LiftResponse}
import _root_.net.liftweb.http.js.JsCmds._
import _root_.net.liftweb.http.js.JE._
import _root_.net.liftweb.common.{Box,Empty,Failure,Full}
import _root_.net.liftweb.util.{Log}
import net.liftweb.http.js.JsCmds._
import net.liftweb.http.js.JE._
import net.liftweb.common.{Box,Empty,Failure,Full}
import net.liftweb.util.{Log}
import net.liftweb.common.ParseDouble

/**
* A helper widget that makes it easy to do upload
Expand Down Expand Up @@ -77,13 +78,13 @@ object UploadProgress {
* </code></pre>
*/
def progressJsonResponse: Full[LiftResponse] = {
val recived: Double = StatusHolder.is.map(_._1.toDouble).openOr(0D)
val size: Double = StatusHolder.is.map(_._2.toDouble).openOr(0D)
val recived: Double = StatusHolder.is.map(v => (v._1.toDouble)).openOr(0D)
val size: Double = StatusHolder.is.map(v => (v._2.toDouble)).openOr(0D)
val state: String = if(recived == size){ "completed" } else { "uploading" }
Full(JsonResponse(
JsObj(
"state" -> state,
"percentage" -> Str(Math.floor((recived.toDouble / size.toDouble)*100).toString)
"percentage" -> Str(Math.floor(((recived) / (size))*100).toString)
)
))
}
Expand Down Expand Up @@ -142,6 +143,3 @@ object UploadProgress {
*/
object StatusHolder extends SessionVar[Box[(Long, Long)]](Empty)

}
}
}

0 comments on commit 065ae99

Please sign in to comment.