Skip to content

Commit

Permalink
Merge branch '6.1' into 6.2
Browse files Browse the repository at this point in the history
# Conflicts:
#	loader/build.xml
#	loader/pom.xml
  • Loading branch information
michaeloffner committed Sep 18, 2024
2 parents c2d7ccb + a7e14dd commit d3955d5
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 41 deletions.
19 changes: 8 additions & 11 deletions core/src/main/java/lucee/runtime/ComponentPageImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import lucee.commons.io.res.util.ResourceUtil;
import lucee.commons.lang.CFTypes;
import lucee.commons.lang.ExceptionUtil;
import lucee.commons.lang.HTMLEntities;
import lucee.commons.lang.StringUtil;
import lucee.commons.lang.mimetype.MimeType;
import lucee.commons.net.HTTPUtil;
Expand Down Expand Up @@ -398,7 +397,7 @@ private void callRest(PageContext pc, Component component, String path, Result r
catch (NumberFormatException ne) {
status = 500;
}
RestUtil.setStatus(pc, status, cte.getMessage());
RestUtil.setStatus(pc, status, cte.getMessage(), true);
return;
}
else {
Expand Down Expand Up @@ -426,7 +425,7 @@ private void callRest(PageContext pc, Component component, String path, Result r
else {
msg = prefix;
}
RestUtil.setStatus(pc, 404, HTMLEntities.escapeHTML(msg));
RestUtil.setStatus(pc, 404, msg, true);
ThreadLocalPageContext.getLog(pc, "rest").info("REST", prefix + " in" + addDetail);
}
else if (status == 405) {
Expand All @@ -437,7 +436,7 @@ else if (status == 405) {
else {
msg = prefix;
}
RestUtil.setStatus(pc, 405, HTMLEntities.escapeHTML(msg));
RestUtil.setStatus(pc, 405, msg, true);
ThreadLocalPageContext.getLog(pc, "rest").info("REST", prefix + " for" + addDetail);
}
else if (status == 406) {
Expand All @@ -448,7 +447,7 @@ else if (status == 406) {
else {
msg = prefix;
}
RestUtil.setStatus(pc, 406, HTMLEntities.escapeHTML(msg));
RestUtil.setStatus(pc, 406, msg, true);
ThreadLocalPageContext.getLog(pc, "rest").info("REST", prefix + " for" + addDetail);
}

Expand All @@ -473,7 +472,7 @@ private void _callThroughSubresourceLocator(PageContext pc, Component component,
callRest(pc, subcomp, path, result, suppressContent);
}
else {
RestUtil.setStatus(pc, 500, "Subresource locator error.");
RestUtil.setStatus(pc, 500, "Subresource locator error.", false);
}
}

Expand Down Expand Up @@ -557,11 +556,9 @@ else if (!"body".equalsIgnoreCase(restArgSource)) {
if (PageContextUtil.show(pc)) {
throw e;
}
else {
ThreadLocalPageContext.getLog(pc, "rest").error("REST", e);
RestUtil.setStatus(pc, 500, ExceptionUtil.getMessage(e, true));
return null;
}
ThreadLocalPageContext.getLog(pc, "rest").error("REST", e);
RestUtil.setStatus(pc, 500, ExceptionUtil.getMessage(e, true), true);
return null;
}
finally {
if (suppressContent) pc.unsetSilent();
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/lucee/runtime/PageContextImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2572,7 +2572,7 @@ public void executeRest(String realPath, boolean throwExcpetion) throws PageExce
throw Caster.toPageException(e);
}
}
else RestUtil.setStatus(this, 404, null);
else RestUtil.setStatus(this, 404, null, false);
return;
}

Expand Down Expand Up @@ -2678,7 +2678,7 @@ else if (StringUtil.endsWithIgnoreCase(pathInfo, ".java")) {
// base = PageSourceImpl.best(config.getPageSources(this,null,realPath,true,false,true));

if (mapping == null || mapping.getPhysical() == null) {
RestUtil.setStatus(this, 404, "no rest service for [" + HTMLEntities.escapeHTML(pathInfo) + "] found");
RestUtil.setStatus(this, 404, "no rest service for [" + HTMLEntities.escapeHTML(pathInfo) + "] found", false);
getLog("rest").error("REST", "no rest service for [" + pathInfo + "] found");
}
else {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/lucee/runtime/config/ConfigFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static UpdateInfo getNew(CFMLEngine engine, Resource contextDir, final bo

// if the config got deleted, we need to make sure the required extension get installed again
boolean deleted = false;
if (readOnly && !ConfigServerFactory.getConfigFile(contextDir).exists()) {
if (readOnly && !ConfigServerFactory.getConfigFile(contextDir, true).exists()) {
deleted = resOldVersion.delete();
}

Expand Down
37 changes: 22 additions & 15 deletions core/src/main/java/lucee/runtime/config/ConfigServerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

public final class ConfigServerFactory extends ConfigFactory {

public static final String CONFIG_FILE_NAME = ".CFConfig.json";
public static final String[] CONFIG_FILE_NAMES = new String[] { ".CFConfig.json", "config.json" };

/**
* creates a new ServletConfig Impl Object
Expand Down Expand Up @@ -110,7 +110,7 @@ public static ConfigServerImpl newInstance(CFMLEngineImpl engine, Map<String, CF
Resource configFileOld = configDir.getRealResource("lucee-server.xml");

// config file
Resource configFileNew = getConfigFile(configDir);
Resource configFileNew = getConfigFile(configDir, true);

boolean hasConfigOld = false;
boolean hasConfigNew = configFileNew.exists() && configFileNew.length() > 0;
Expand Down Expand Up @@ -175,24 +175,31 @@ public static ConfigServerImpl newInstance(CFMLEngineImpl engine, Map<String, CF
}
}

public static Resource getConfigFile(Resource configDir) throws IOException {
public static Resource getConfigFile(Resource configDir, boolean server) throws IOException {
if (server) {
// lucee.base.config
String customCFConfig = SystemUtil.getSystemPropOrEnvVar("lucee.base.config", null);
Resource configFile = null;
if (!StringUtil.isEmpty(customCFConfig, true)) {

// lucee.base.config
String customCFConfig = SystemUtil.getSystemPropOrEnvVar("lucee.base.config", null);
Resource configFile = null;
if (!StringUtil.isEmpty(customCFConfig, true)) {
configFile = ResourcesImpl.getFileResourceProvider().getResource(customCFConfig.trim());

configFile = ResourcesImpl.getFileResourceProvider().getResource(customCFConfig.trim());

if (configFile.isFile()) {
LogUtil.log(Log.LEVEL_INFO, "deploy", "config", "using config File : " + configFile);
return configFile;
if (configFile.isFile()) {
LogUtil.log(Log.LEVEL_INFO, "deploy", "config", "using config File : " + configFile);
return configFile;
}
throw new IOException(
"the config file [" + configFile + "] defined with the environment variable [LUCEE_BASE_CONFIG] or system property [-Dlucee.base.config] does not exist.");
}
throw new IOException(
"the config file [" + configFile + "] defined with the environment variable [LUCEE_BASE_CONFIG] or system property [-Dlucee.base.config] does not exist.");
}
Resource res;
for (String cf: CONFIG_FILE_NAMES) {
res = configDir.getRealResource(cf);
if (res.isFile()) return res;
}

// default location
return configDir.getRealResource(CONFIG_FILE_NAME);
return configDir.getRealResource(CONFIG_FILE_NAMES[0]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public static ConfigWebPro newInstanceMulti(CFMLEngine engine, CFMLFactoryImpl f

boolean doNew = getNew(engine, configDir, false, UpdateInfo.NEW_NONE).updateType != NEW_NONE;
Resource configFileOld = configDir.getRealResource("lucee-web.xml." + TEMPLATE_EXTENSION);
Resource configFileNew = configDir.getRealResource(ConfigServerFactory.CONFIG_FILE_NAME);
Resource configFileNew = ConfigServerFactory.getConfigFile(configDir, false);
String strPath = servletConfig.getServletContext().getRealPath("/WEB-INF");
Resource path = ResourcesImpl.getFileResourceProvider().getResource(strPath);
boolean hasConfigOld = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static Struct call(PageContext pc, Object pathOrData, String type, String
if (pathOrData instanceof CharSequence) res = ResourceUtil.toResourceExisting(pc, pathOrData.toString());
else if (pathOrData instanceof Map) data = Caster.toStruct(pathOrData);
else throw new FunctionException(pc, "ConfigFileImport", "first", "pathOrData",
"Invalid value for argument pathOrData, the argument must contain a string that points to a " + ConfigServerFactory.CONFIG_FILE_NAME
"Invalid value for argument pathOrData, the argument must contain a string that points to a " + ConfigServerFactory.CONFIG_FILE_NAMES[0]
+ " file or a struct containing the data itself.",
null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ else if ("server".equalsIgnoreCase(source.trim())) {
if (!StringUtil.isEmpty(target, true)) {
if ("web".equalsIgnoreCase(target.trim())) {
Resource dir = ((ConfigWebPro) config).getWebConfigDir();
trg = dir.getRealResource(ConfigServerFactory.CONFIG_FILE_NAME);
trg = ConfigServerFactory.getConfigFile(dir, false);
}
else if ("server".equalsIgnoreCase(target.trim())) {
trg = ConfigServerFactory.getConfigFile(pc.getConfig().getConfigServerDir());
trg = ConfigServerFactory.getConfigFile(pc.getConfig().getConfigServerDir(), true);
}
if (trg == null) trg = Caster.toResource(pc, target, false);
if (!trg.getParentResource().isDirectory())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import javax.servlet.http.HttpServletRequest;

import lucee.commons.lang.HTMLEntities;
import lucee.commons.lang.mimetype.MimeType;
import lucee.runtime.PageContext;
import lucee.runtime.PageSource;
Expand Down Expand Up @@ -76,11 +75,11 @@ public PageSource execute(PageContext pc, PageSource requestedPage) throws PageE
+ ListUtil.listToListEL(sources, ", ") + "]";

if (PageContextUtil.show(pc)) {
RestUtil.setStatus(pc, 404, HTMLEntities.escapeHTML(msg + addDetail));
RestUtil.setStatus(pc, 404, msg + addDetail, true);

}
else {
RestUtil.setStatus(pc, 404, HTMLEntities.escapeHTML(msg));
RestUtil.setStatus(pc, 404, msg, true);

}
ThreadLocalPageContext.getLog(pc, "rest").info("REST", msg + addDetail);
Expand Down
8 changes: 5 additions & 3 deletions core/src/main/java/lucee/runtime/rest/RestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

import lucee.commons.io.res.Resource;
import lucee.commons.io.res.util.ResourceUtil;
import lucee.commons.lang.HTMLEntities;
import lucee.commons.lang.StringUtil;
import lucee.runtime.PageContext;
import lucee.runtime.rest.path.Path;
import lucee.runtime.type.Struct;
Expand Down Expand Up @@ -60,11 +62,11 @@ public static int matchPath(Struct variables, Path[] restPath, String[] callerPa
* @param status
* @param msg
*/
public static void setStatus(PageContext pc, int status, String msg) {
public static void setStatus(PageContext pc, int status, String msg, boolean htmlEscapeMessage) {
pc.clear();
if (msg != null) {
if (!StringUtil.isEmpty(msg)) {
try {
pc.forceWrite(msg);
pc.forceWrite(htmlEscapeMessage ? HTMLEntities.escapeHTML(msg) : msg);
}
catch (IOException e) {
}
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.2.0.89-SNAPSHOT"/>
<property name="version" value="6.2.0.90-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.2.0.89-SNAPSHOT</version>
<version>6.2.0.90-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Lucee Loader Build</name>
Expand Down
25 changes: 25 additions & 0 deletions test/tickets/LDEV5092.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
component extends="org.lucee.cfml.test.LuceeTestCase" skip=true {

function run( testResults , testBox ) {
describe( title='LDEV-5092', body=function(){
it( title='trigger java.util.ConcurrentModificationException', body=function() {
var a = [];
ArraySet(a,1,1000,"");
ArrayEach(a, testJava, true);
});
});
}

private function testJava(){
var oRegExMatcher = createObject("java", "java.util.regex.Matcher");
var re = oRegExMatcher.quoteReplacement( "(?i)<!-- $$blah$$ -->" ); // NPE
var re2 = oRegExMatcher.quoteReplacement( javacast("string", "1") );
var sReturn = "string";
sReturn.replaceAll(
oRegExMatcher.quoteReplacement( "(?i)<!-- $$blah$$ -->" ),
oRegExMatcher.quoteReplacement( javacast("string", "1") )
);
sReturn.replaceAll( re, re2 );
return sReturn;
}
}

0 comments on commit d3955d5

Please sign in to comment.