Skip to content

Commit

Permalink
rename "limitIsDefined to "limitEvaluation" and extend it for more fu…
Browse files Browse the repository at this point in the history
…nctions
  • Loading branch information
michaeloffner committed Sep 8, 2023
1 parent 8fa5374 commit cc616ec
Show file tree
Hide file tree
Showing 18 changed files with 67 additions and 63 deletions.
2 changes: 1 addition & 1 deletion core/src/main/cfml/context/admin/overview.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Defaults --->
<cfset error.detail="">
<cfparam name="form.mainAction" default="none">
<!--- load asynchron all extension providers --->
<cfparam name="application[request.admintype].preloadedExtensionProviders" default="false" type="boolean">
<cfif isNull(application[request.admintype].preloadedExtensionProviders)><cfset application[request.admintype].preloadedExtensionProviders=false></cfif>
<cfif !application[request.admintype].preloadedExtensionProviders>
<cfinclude template="ext.functions.cfm">
<cfset application[request.admintype].preloadedExtensionProviders=true>
Expand Down
21 changes: 11 additions & 10 deletions core/src/main/cfml/context/admin/server.security.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Defaults --->
action="updateSecurity"
type="#request.adminType#"
password="#session["password"&request.adminType]#"
limitIsDefined="#form.limitIsDefined?:false#"
limitEvaluation="#form.limitEvaluation?:false#"
varUsage="#form.varUsage#"
remoteClients="#request.getRemoteClients()#">

Expand All @@ -44,7 +44,7 @@ Defaults --->
action="updateSecurity"
type="#request.adminType#"
password="#session["password"&request.adminType]#"
limitIsDefined=""
limitEvaluation=""
varUsage=""
remoteClients="#request.getRemoteClients()#">

Expand Down Expand Up @@ -109,23 +109,24 @@ Error Output --->
</tr>
<cfscript>
stText.security.limitIsDefined="Limit function IsDefined";
stText.security.limitIsDefinedDesc="If enable you can use expression within of [] in variable name checked by the function Isdefined like this: susi[getVariableName()]";
stText.security.limitEvaluation="Limit variable evaluation in functions/tags";
stText.security.limitEvaluationDesc="If enable you cannot use expression within ""[ ]"" like this susi[getVariableName()] .
This affects the following functions [IsDefined, structGet, empty] and the following tags [savecontent attribute ""variable""].";
</cfscript>
<!--- limit function isDefined --->
<tr>
<th scope="row">#stText.security.limitIsDefined#</th>
<th scope="row">#stText.security.limitEvaluation#</th>
<td>
<cfif hasAccess>
<input type="checkbox" class="checkbox" <cfif (security.limitIsDefined?:true)> checked="checked"</cfif> name="limitIsDefined" value="true" />
<input type="checkbox" class="checkbox" <cfif (security.limitEvaluation?:true)> checked="checked"</cfif> name="limitEvaluation" value="true" />
<cfelse>
<input type="hidden" name="limitIsDefined" value="#security.limitIsDefined?:true#">
<b>#yesNoFormat(security.limitIsDefined)#</b>
<input type="hidden" name="limitEvaluation" value="#security.limitEvaluation?:true#">
<b>#yesNoFormat(security.limitEvaluation)#</b>
</cfif>
<div class="comment">#stText.security.limitIsDefinedDesc#</div>
<div class="comment">#stText.security.limitEvaluationDesc#</div>
<cfsavecontent variable="codeSample">
this.security.limitIsDefined=#security.limitIsDefined?:true#;
this.security.limitEvaluation=#security.limitEvaluation?:true#;
</cfsavecontent>
<cfset renderCodingTip( codeSample)>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ list all mappings and display necessary edit fields --->
<td class="tblContent#css# longwords"><input type="hidden" name="name_#srcLocal.currentrow#" value="#srcLocal.name#">#srcLocal.name#</td>
<td class="tblContent#css# longwords">#label#
<cfif !hasDriver><div class="commentError">#stText.Settings.noDriver#</div></cfif>
<cfif isDefined( "stVerifyMessages[srcLocal.name].dbInfo" ) && stVerifyMessages[srcLocal.name].dbInfo.recordCount>
<cfif !isNull( stVerifyMessages[srcLocal.name].dbInfo ) && stVerifyMessages[srcLocal.name].dbInfo.recordCount>
<cfset qDbInfo = stVerifyMessages[srcLocal.name].dbInfo>
<div class="comment">#stText.settings.datasource.databaseName#: #qDbInfo.DATABASE_PRODUCTNAME# #qDbInfo.DATABASE_VERSION#</div>
<div class="comment">#stText.settings.datasource.driverName#: #qDbInfo.DRIVER_NAME# #qDbInfo.DRIVER_VERSION# (JDBC #qDbInfo.JDBC_MAJOR_VERSION#.#qDbInfo.JDBC_MINOR_VERSION#)</div>
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/lucee/runtime/PageContextImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3903,8 +3903,8 @@ private static synchronized int getIdCounter() {
return _idCounter;
}

public boolean limitIsDefined() {
if (applicationContext != null) return applicationContext.getLimitIsDefined();
return ((ConfigPro) config).limitIsDefined();
public boolean limitEvaluation() {
if (applicationContext != null) return applicationContext.getLimitEvaluation();
return ((ConfigPro) config).limitEvaluation();
}
}
6 changes: 3 additions & 3 deletions core/src/main/java/lucee/runtime/config/ConfigAdmin.java
Original file line number Diff line number Diff line change
Expand Up @@ -3046,16 +3046,16 @@ public void updateCTPathCache(Boolean ctPathCache) throws SecurityException {
root.setEL("customTagUseCachePath", Caster.toString(ctPathCache, ""));
}

public void updateSecurity(String varUsage, Boolean limitIsDefined) throws SecurityException {
public void updateSecurity(String varUsage, Boolean limitEvaluation) throws SecurityException {
checkWriteAccess();
Struct el = _getRootElement("security");

if (el != null) {
if (!StringUtil.isEmpty(varUsage)) el.setEL("variableUsage", Caster.toString(varUsage));
else rem(el, "variableUsage");

if (limitIsDefined != null) el.setEL("limitIsDefined", limitIsDefined);
else rem(el, "limitIsDefined");
if (limitEvaluation != null) el.setEL("limitEvaluation", limitEvaluation);
else rem(el, "limitEvaluation");
}

}
Expand Down
10 changes: 5 additions & 5 deletions core/src/main/java/lucee/runtime/config/ConfigImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public abstract class ConfigImpl extends ConfigBase implements ConfigPro {

private short type = SCOPE_STANDARD;
private boolean _allowImplicidQueryCall = true;
private boolean _limitIsDefined = false;
private boolean _limitEvaluation = false;

private boolean _mergeFormAndURL = false;

Expand Down Expand Up @@ -558,8 +558,8 @@ public boolean allowImplicidQueryCall() {
}

@Override
public boolean limitIsDefined() {
return _limitIsDefined;
public boolean limitEvaluation() {
return _limitEvaluation;
}

@Override
Expand Down Expand Up @@ -1235,8 +1235,8 @@ protected void setAllowImplicidQueryCall(boolean _allowImplicidQueryCall) {
this._allowImplicidQueryCall = _allowImplicidQueryCall;
}

protected void setLimitIsDefined(boolean _limitIsDefined) {
this._limitIsDefined = _limitIsDefined;
protected void setLimitEvaluation(boolean _limitEvaluation) {
this._limitEvaluation = _limitEvaluation;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/lucee/runtime/config/ConfigPro.java
Original file line number Diff line number Diff line change
Expand Up @@ -358,5 +358,5 @@ public interface ConfigPro extends Config {

public void setLastModified();

public boolean limitIsDefined();
public boolean limitEvaluation();
}
16 changes: 8 additions & 8 deletions core/src/main/java/lucee/runtime/config/ConfigWebFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -4049,21 +4049,21 @@ private static void _loadScope(ConfigServerImpl configServer, ConfigImpl config,

// limit isdefined
if (mode == ConfigPro.MODE_STRICT) {
config.setLimitIsDefined(true);
config.setLimitEvaluation(true);
}
else {
Boolean limitIsDefined = Caster.toBoolean(SystemUtil.getSystemPropOrEnvVar("lucee.isdefined.limit", null), null);
if (limitIsDefined == null) limitIsDefined = Caster.toBoolean(SystemUtil.getSystemPropOrEnvVar("lucee.security.isdefined", null), null);
if (limitIsDefined == null) {
Boolean limitEvaluation = Caster.toBoolean(SystemUtil.getSystemPropOrEnvVar("lucee.isdefined.limit", null), null);
if (limitEvaluation == null) limitEvaluation = Caster.toBoolean(SystemUtil.getSystemPropOrEnvVar("lucee.security.isdefined", null), null);
if (limitEvaluation == null) {
Struct security = ConfigWebUtil.getAsStruct("security", root);
if (security != null) {
limitIsDefined = Caster.toBoolean(getAttr(security, "limitIsDefined"), null);
limitEvaluation = Caster.toBoolean(getAttr(security, "limitEvaluation"), null);
}
}
if (hasAccess && limitIsDefined != null) {
config.setLimitIsDefined(limitIsDefined.booleanValue());
if (hasAccess && limitEvaluation != null) {
config.setLimitEvaluation(limitEvaluation.booleanValue());
}
else if (hasCS) config.setLimitIsDefined(configServer.limitIsDefined());
else if (hasCS) config.setLimitEvaluation(configServer.limitEvaluation());
}

// Merge url and Form
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/lucee/runtime/config/ConfigWebImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,8 @@ public boolean allowImplicidQueryCall() {
}

@Override
public boolean limitIsDefined() {
return instance.limitIsDefined();
public boolean limitEvaluation() {
return instance.limitEvaluation();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ public boolean allowImplicidQueryCall() {
}

@Override
public boolean limitIsDefined() {
return cs.limitIsDefined();
public boolean limitEvaluation() {
return cs.limitEvaluation();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ else if (scope instanceof Undefined) {
* @throws SecurityInterpreterException
*/
public static Object getVariableEL(PageContext pc, String var, Object defaultValue) throws SecurityInterpreterException {
StringList list = parse(pc, new ParserString(var), false, false);
StringList list = parse(pc, new ParserString(var), false, ((PageContextImpl) pc).limitEvaluation());
if (list == null) return defaultValue;
Object _null = NullSupportHelper.NULL(pc);

Expand Down Expand Up @@ -427,7 +427,7 @@ public static Object removeVariable(PageContext pc, String var) throws PageExcep
* @throws SecurityInterpreterException
*/
public static boolean isDefined(PageContext pc, String var) throws SecurityInterpreterException {
StringList list = parse(pc, new ParserString(var), false, ((PageContextImpl) pc).limitIsDefined());
StringList list = parse(pc, new ParserString(var), false, ((PageContextImpl) pc).limitEvaluation());
if (list == null) return false;
try {
int scope = scopeString2Int(pc.ignoreScopes(), list.next());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ private static LoggerAndSourceData addLogger(Collection.Key name, int level, Cla

public abstract void setPreciseMath(boolean preciseMath);

public abstract boolean getLimitIsDefined();
public abstract boolean getLimitEvaluation();

public abstract void setLimitIsDefined(boolean limitIsDefined);
public abstract void setLimitEvaluation(boolean limitEvaluation);

}
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public class ClassicApplicationContext extends ApplicationContextSupport {
private Map<Key, Object> customAttrs;

private boolean allowImplicidQueryCall;
private boolean limitIsDefined;
private boolean limitEvaluation;
private Regex regex;

private boolean preciseMath;
Expand Down Expand Up @@ -190,7 +190,7 @@ public ClassicApplicationContext(ConfigWeb config, String name, boolean isDefaul
this.fullNullSupport = config.getFullNullSupport();
this.scopeCascading = config.getScopeCascadingType();
this.allowImplicidQueryCall = config.allowImplicidQueryCall();
this.limitIsDefined = ((ConfigPro) config).limitIsDefined();
this.limitEvaluation = ((ConfigPro) config).limitEvaluation();

this.webCharset = ((ConfigPro) config).getWebCharSet();
this.resourceCharset = ((ConfigPro) config).getResourceCharSet();
Expand Down Expand Up @@ -264,7 +264,7 @@ public ApplicationContext duplicate() {
dbl.fullNullSupport = fullNullSupport;
dbl.scopeCascading = scopeCascading;
dbl.allowImplicidQueryCall = allowImplicidQueryCall;
dbl.limitIsDefined = limitIsDefined;
dbl.limitEvaluation = limitEvaluation;
dbl.webCharset = webCharset;
dbl.resourceCharset = resourceCharset;
dbl.sessionType = sessionType;
Expand Down Expand Up @@ -881,13 +881,13 @@ public void setAllowImplicidQueryCall(boolean allowImplicidQueryCall) {
}

@Override
public boolean getLimitIsDefined() {
return limitIsDefined;
public boolean getLimitEvaluation() {
return limitEvaluation;
}

@Override
public void setLimitIsDefined(boolean limitIsDefined) {
this.limitIsDefined = limitIsDefined;
public void setLimitEvaluation(boolean limitEvaluation) {
this.limitEvaluation = limitEvaluation;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public class ModernApplicationContext extends ApplicationContextSupport {
private static final Key XML_FEATURES = KeyImpl.getInstance("xmlFeatures");
private static final Key SEARCH_QUERIES = KeyImpl.getInstance("searchQueries");
private static final Key SEARCH_RESULTS = KeyImpl.getInstance("searchResults");
private static final Key LIMIT_ISDEFINED = KeyImpl.getInstance("limitIsDefined");
private static final Key LIMIT_EVALUATION = KeyImpl.getInstance("limitEvaluation");
private static final Key REGEX = KeyImpl.getInstance("regex");
private static final Key ENGINE = KeyImpl.getInstance("engine");
private static final Key DIALECT = KeyConstants._dialect;
Expand Down Expand Up @@ -312,7 +312,7 @@ public class ModernApplicationContext extends ApplicationContextSupport {
private boolean initFuncDirs = false;

private boolean allowImplicidQueryCall;
private boolean limitIsDefined;
private boolean limitEvaluation;
private Regex regex;

public ModernApplicationContext(PageContext pc, Component cfc, RefBoolean throwsErrorWhileInit) {
Expand Down Expand Up @@ -351,7 +351,7 @@ public ModernApplicationContext(PageContext pc, Component cfc, RefBoolean throws
this.sessionStorage = ci.getSessionStorage();
this.clientStorage = ci.getClientStorage();
this.allowImplicidQueryCall = config.allowImplicidQueryCall();
this.limitIsDefined = ci.limitIsDefined();
this.limitEvaluation = ci.limitEvaluation();
this.triggerComponentDataMember = config.getTriggerComponentDataMember();
this.restSetting = config.getRestSetting();
this.javaSettings = new JavaSettingsImpl();
Expand All @@ -366,7 +366,7 @@ public ModernApplicationContext(PageContext pc, Component cfc, RefBoolean throws
initSameFieldAsArray(pc);
initWebCharset(pc);
initAllowImplicidQueryCall();
initLimitIsDefined();
initLimitEvaluation();

pc.addPageSource(component.getPageSource(), true);
try {
Expand Down Expand Up @@ -402,13 +402,13 @@ private void initAllowImplicidQueryCall() {
if (o != null) allowImplicidQueryCall = Caster.toBooleanValue(o, allowImplicidQueryCall);
}

private void initLimitIsDefined() {
private void initLimitEvaluation() {
Object o = get(component, KeyConstants._security, null);

if (o instanceof Struct) {
Struct sct = (Struct) o;
o = sct.get(LIMIT_ISDEFINED, null);
if (o != null) limitIsDefined = Caster.toBooleanValue(o, limitIsDefined);
o = sct.get(LIMIT_EVALUATION, null);
if (o != null) limitEvaluation = Caster.toBooleanValue(o, limitEvaluation);

}
}
Expand Down Expand Up @@ -1916,13 +1916,13 @@ public void setXmlFeatures(Struct xmlFeatures) {
}

@Override
public boolean getLimitIsDefined() {
return limitIsDefined;
public boolean getLimitEvaluation() {
return limitEvaluation;
}

@Override
public void setLimitIsDefined(boolean limitIsDefined) {
this.limitIsDefined = limitIsDefined;
public void setLimitEvaluation(boolean limitEvaluation) {
this.limitEvaluation = limitEvaluation;
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/lucee/runtime/tag/Admin.java
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ private void doGetSecurity() throws PageException {
pageContext.setVariable(getString("admin", action, "returnVariable"), sct);

sct.set("varUsage", AppListenerUtil.toVariableUsage(config.getQueryVarUsage(), "ignore"));
sct.set("limitIsDefined", config.limitIsDefined());
sct.set("limitEvaluation", config.limitEvaluation());
}

/**
Expand Down Expand Up @@ -1759,7 +1759,7 @@ private Double _fillSecDataDS(short access) {
}

private void doUpdateSecurity() throws PageException {
admin.updateSecurity(getString("varUsage", ""), getBool("limitIsDefined", null));
admin.updateSecurity(getString("varUsage", ""), getBool("limitEvaluation", null));
store();
adminSync.broadcast(attributes, config);
}
Expand Down
5 changes: 4 additions & 1 deletion core/src/main/java/lucee/runtime/tag/SaveContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ public int doAfterBody() throws PageException {
String value = trim ? bodyContent.getString().trim() : bodyContent.getString();

if (append) {
value = Caster.toString(VariableInterpreter.getVariableEL(pageContext, variable, ""), "") + value; // prepend the current variable or empty-string if not found
value = Caster.toString(VariableInterpreter.getVariableEL(pageContext, variable, ""), "") + value; // prepend the
// current
// variable or empty-string
// if not found
}
pageContext.setVariable(variable, value);
bodyContent.clearBody();
Expand Down
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.537-SNAPSHOT"/>
<property name="version" value="6.0.0.538-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.537-SNAPSHOT</version>
<version>6.0.0.538-SNAPSHOT</version>
<packaging>jar</packaging>

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

0 comments on commit cc616ec

Please sign in to comment.