Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes a stack overflow on certain combinations

  • Loading branch information...
commit cbebcead73974d323ce3954de7934e4663d9ef46 1 parent 0705eb6
@dpp dpp authored
View
15 core/util/src/main/scala/net/liftweb/util/BindHelpers.scala
@@ -1825,14 +1825,23 @@ class ClearClearable extends CssBindImpl(Full(".clearable"), CssSelectorParser.p
object ClearClearable extends ClearClearable
private class SelectorMap(binds: List[CssBind]) extends Function1[NodeSeq, NodeSeq] {
- private def sortBinds(lst: List[CssBind]): List[CssBind] =
+
+ // The KidsSubNode always has to go last or else we
+ // get into an issue where we're trying to apply the whole
+ // transform to the whole shooting match
+ private def sortBinds(lst: List[CssBind]): List[CssBind] = {
lst.sort {
case (SubNode(me: EmptyBox), SubNode(_)) => true
case (SubNode(_), SubNode(them: EmptyBox)) => false
- case (SubNode(Full(KidsSubNode())), SubNode(_)) => true
- case (SubNode(_), SubNode(Full(KidsSubNode()))) => false
+ case (SubNode(Full(KidsSubNode())), SubNode(_)) => false
+ case (SubNode(Full(PrependKidsSubNode())), SubNode(_)) => false
+ case (SubNode(Full(AppendKidsSubNode())), SubNode(_)) => false
+ case (SubNode(_), SubNode(Full(KidsSubNode()))) => true
+ case (SubNode(_), SubNode(Full(PrependKidsSubNode()))) => true
+ case (SubNode(_), SubNode(Full(AppendKidsSubNode()))) => true
case _ => true
}
+ }
private val (idMap, nameMap, clzMap, attrMap, elemMap,
starFunc, selectThis: Box[CssBind]) = {
View
21 core/util/src/test/scala/net/liftweb/util/BindHelpersSpec.scala
@@ -396,6 +396,27 @@ object CssBindHelpersSpec extends Specification {
(res \ "@id").text must_== "moo"
}
+ "not stack overflow on Elem" in {
+ val xf = "* [id]" #> "xx" &
+ "* [style]" #> "border:thin solid black" &
+ "* *" #> <a/>
+ }
+
+ "not stack overflow on Elem" in {
+ val xf = "* [id]" #> "xx" &
+ "* [style]" #> "border:thin solid black" &
+ "* *+" #> <a/>
+
+ xf(<div/>)
+ }
+
+ "not stack overflow on Elem" in {
+ val xf = "* [id]" #> "xx" &
+ "* [style]" #> "border:thin solid black" &
+ "* -*" #> <a/>
+
+ xf(<div/>)
+ }
"substitute a String by id" in {
("#foo" replaceWith "hello")(<b><span id="foo"/></b>) must ==/ (<b>hello</b>)
Please sign in to comment.
Something went wrong with that request. Please try again.