Skip to content

Commit

Permalink
LDEV-3707 - change test if client has send cookies or not and if type…
Browse files Browse the repository at this point in the history
… jee send no cfid/cftoken
  • Loading branch information
michaeloffner committed Oct 11, 2023
1 parent 8554ddd commit ad3cca1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,30 @@
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 {

private static final long serialVersionUID = 1486918425114400713L;

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);
}
}

Expand All @@ -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();
}
}
2 changes: 1 addition & 1 deletion loader/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project default="core" basedir="." name="Lucee"
xmlns:resolver="antlib:org.apache.maven.resolver.ant">

<property name="version" value="6.0.0.579-SNAPSHOT"/>
<property name="version" value="6.0.0.580-SNAPSHOT"/>

<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
<classpath>
Expand Down
2 changes: 1 addition & 1 deletion loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.lucee</groupId>
<artifactId>lucee</artifactId>
<version>6.0.0.579-SNAPSHOT</version>
<version>6.0.0.580-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Lucee Loader Build</name>
Expand Down

0 comments on commit ad3cca1

Please sign in to comment.