From fa78d5200ff9569ef2f63470fead8a6511f89e1e Mon Sep 17 00:00:00 2001 From: Matt Farmer Date: Thu, 24 Aug 2017 22:52:17 -0400 Subject: [PATCH 1/6] Provide context path to comet session reload function --- web/webkit/src/main/resources/toserve/lift.js | 12 ++++++++---- .../src/main/scala/net/liftweb/http/LiftRules.scala | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/web/webkit/src/main/resources/toserve/lift.js b/web/webkit/src/main/resources/toserve/lift.js index 1b1e5f1c0a..86dc28ab69 100644 --- a/web/webkit/src/main/resources/toserve/lift.js +++ b/web/webkit/src/main/resources/toserve/lift.js @@ -76,8 +76,12 @@ }, cometGetTimeout: 140000, cometFailureRetryTimeout: 10000, - cometOnSessionLost: function() { - window.location.href = "/"; + cometOnSessionLost: function(contextPath) { + if (contextPath === null || contextPath === undefined) { + window.location.href = "/"; + } else { + window.location.href = contextPath; + } }, cometServer: null, cometOnError: function(e) { @@ -711,7 +715,7 @@ if (typeof elementOrId === 'string') { element = document.getElementById(elementOrId); } - + // This is a Lift addition to allow return false to properly do // cross-browser preventDefault/stopPropagation/etc work. function normalizeEventReturn(event) { @@ -722,7 +726,7 @@ event.stopPropagation(); } } - + return result; } diff --git a/web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala b/web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala index cc68c9b18f..89d92f5bcb 100644 --- a/web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala +++ b/web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala @@ -775,7 +775,7 @@ class LiftRules() extends Factory with FormVendor with LazyLoggable { * lift.cometOnSessionLost reloads the current page by default. */ val noCometSessionCmd = new FactoryMaker[JsCmd]( - () => JsCmds.Run("lift.cometOnSessionLost()") + () => JsCmds.Run(s"lift.cometOnSessionLost('${S.contextPath}')") ) {} /** From af1601f2cce4eb3a1b06d50d18626581fa582cba Mon Sep 17 00:00:00 2001 From: Josef Vlach Date: Mon, 28 Aug 2017 21:04:26 +0100 Subject: [PATCH 2/6] Pass contextPath to settings.cometOnSessionLost --- web/webkit/src/main/resources/toserve/lift.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/webkit/src/main/resources/toserve/lift.js b/web/webkit/src/main/resources/toserve/lift.js index 86dc28ab69..1da92f990e 100644 --- a/web/webkit/src/main/resources/toserve/lift.js +++ b/web/webkit/src/main/resources/toserve/lift.js @@ -606,8 +606,8 @@ }, calcAjaxUrl: calcAjaxUrl, registerComets: registerComets, - cometOnSessionLost: function() { - settings.cometOnSessionLost(); + cometOnSessionLost: function(contextPath) { + settings.cometOnSessionLost(contextPath); }, cometOnError: function(e) { settings.cometOnError(e); From aaee41a9f27482a11cc62d8fa5f8588734394709 Mon Sep 17 00:00:00 2001 From: Josef Vlach Date: Wed, 30 Aug 2017 22:10:06 +0100 Subject: [PATCH 3/6] Update of contributors.md --- contributors.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/contributors.md b/contributors.md index 221c5359ea..3a557545ac 100644 --- a/contributors.md +++ b/contributors.md @@ -262,4 +262,10 @@ mroocoo at gmail dot com Riccardo Sirigu ### Email: ### -me@riccardosirigu.com \ No newline at end of file +me@riccardosirigu.com + +### Name: ### +Josef Vlach + +### Email: ### +vlach.josef at gmail dot com From 05587032a93aacb68b4086b366f4f44984f7076e Mon Sep 17 00:00:00 2001 From: Matt Farmer Date: Sun, 10 Sep 2017 20:55:04 -0400 Subject: [PATCH 4/6] Simplify including context path on comet session loss --- web/webkit/src/main/resources/toserve/lift.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/web/webkit/src/main/resources/toserve/lift.js b/web/webkit/src/main/resources/toserve/lift.js index 1da92f990e..bf376f3097 100644 --- a/web/webkit/src/main/resources/toserve/lift.js +++ b/web/webkit/src/main/resources/toserve/lift.js @@ -77,11 +77,7 @@ cometGetTimeout: 140000, cometFailureRetryTimeout: 10000, cometOnSessionLost: function(contextPath) { - if (contextPath === null || contextPath === undefined) { - window.location.href = "/"; - } else { - window.location.href = contextPath; - } + window.location.href = contextPath || "/"; }, cometServer: null, cometOnError: function(e) { From 22f2a51dad0d4dc6e1e0831bfcc7b5819494c132 Mon Sep 17 00:00:00 2001 From: Matt Farmer Date: Sun, 10 Sep 2017 21:00:12 -0400 Subject: [PATCH 5/6] URL encode context path and escape single quotes --- web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala b/web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala index f7edc1dd49..6a1fce3c32 100644 --- a/web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala +++ b/web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala @@ -776,7 +776,7 @@ class LiftRules() extends Factory with FormVendor with LazyLoggable { * lift.cometOnSessionLost reloads the current page by default. */ val noCometSessionCmd = new FactoryMaker[JsCmd]( - () => JsCmds.Run(s"lift.cometOnSessionLost('${S.contextPath}')") + () => JsCmds.Run(s"lift.cometOnSessionLost('${urlEncode(S.contextPath).replace("'", "\\'")}')") ) {} /** From d506eb4b19e1dd65d164ece8a52dd31bce4fa2d5 Mon Sep 17 00:00:00 2001 From: Matt Farmer Date: Tue, 12 Sep 2017 22:14:03 -0400 Subject: [PATCH 6/6] Back out the urlencode when passing context path to client --- web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala b/web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala index cf4a26371c..b96e61141e 100644 --- a/web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala +++ b/web/webkit/src/main/scala/net/liftweb/http/LiftRules.scala @@ -776,7 +776,7 @@ class LiftRules() extends Factory with FormVendor with LazyLoggable { * lift.cometOnSessionLost reloads the current page by default. */ val noCometSessionCmd = new FactoryMaker[JsCmd]( - () => JsCmds.Run(s"lift.cometOnSessionLost('${urlEncode(S.contextPath).replace("'", "\\'")}')") + () => JsCmds.Run(s"lift.cometOnSessionLost('${S.contextPath.replace("'", "\\'")}')") ) {} /**