diff --git a/core/src/main/java/lucee/runtime/functions/other/URLSessionFormat.java b/core/src/main/java/lucee/runtime/functions/other/URLSessionFormat.java index 4686e01350..31294af4ad 100644 --- a/core/src/main/java/lucee/runtime/functions/other/URLSessionFormat.java +++ b/core/src/main/java/lucee/runtime/functions/other/URLSessionFormat.java @@ -25,6 +25,7 @@ import lucee.runtime.config.Config; import lucee.runtime.ext.function.Function; import lucee.runtime.net.http.ReqRspUtil; +import lucee.runtime.type.util.ArrayUtil; public final class URLSessionFormat implements Function { @@ -32,20 +33,22 @@ public final class URLSessionFormat implements Function { public static String call(PageContext pc, String strUrl) { Cookie[] cookies = ReqRspUtil.getCookies(pc.getHttpServletRequest(), pc.getWebCharset()); - - if (!pc.getApplicationContext().isSetClientCookies() || cookies == null) { - int indexQ = strUrl.indexOf('?'); - int indexA = strUrl.indexOf('&'); - int len = strUrl.length(); - if (indexQ == len - 1 || indexA == len - 1) strUrl += getURLToken(pc); - else if (indexQ != -1) strUrl += "&" + getURLToken(pc); - else strUrl += "?" + getURLToken(pc); - - if (pc.getSessionType() == Config.SESSION_TYPE_JEE) { - HttpSession s = pc.getSession(); + if (!pc.getApplicationContext().isSetClientCookies() || ArrayUtil.isEmpty(cookies)) { + HttpSession s; + if (pc.getSessionType() == Config.SESSION_TYPE_APPLICATION) { + int indexQ = strUrl.indexOf('?'); + int indexA = strUrl.indexOf('&'); + int len = strUrl.length(); + if (indexQ == len - 1 || indexA == len - 1) strUrl += getURLToken(pc); + else if (indexQ != -1) strUrl += "&" + getURLToken(pc); + else strUrl += "?" + getURLToken(pc); + } + else if ((s = pc.getSession()) != null) { if (s != null) { - if (indexQ == -1) indexQ = strUrl.indexOf('?'); - strUrl = strUrl.substring(0, indexQ) + ";jsessionid=" + s.getId() + strUrl.substring(indexQ); + int indexQ = strUrl.indexOf('?'); + + if (indexQ != -1) strUrl = strUrl.substring(0, indexQ) + getJSession(s) + strUrl.substring(indexQ); + else strUrl += getJSession(s); } } @@ -56,4 +59,8 @@ public static String call(PageContext pc, String strUrl) { private static String getURLToken(PageContext pc) { return "CFID=" + pc.getCFID() + "&CFTOKEN=" + pc.getCFToken(); } + + private static String getJSession(HttpSession s) { + return ";jsessionid=" + s.getId(); + } } \ No newline at end of file diff --git a/loader/build.xml b/loader/build.xml index af04a81284..185f9e97fd 100644 --- a/loader/build.xml +++ b/loader/build.xml @@ -2,7 +2,7 @@ - + diff --git a/loader/pom.xml b/loader/pom.xml index 34bc381583..b7b0ed59a3 100644 --- a/loader/pom.xml +++ b/loader/pom.xml @@ -3,7 +3,7 @@ org.lucee lucee - 6.0.0.579-SNAPSHOT + 6.0.0.580-SNAPSHOT jar Lucee Loader Build