Improved: Make loading of data containing urls configurable
(OFBIZ-12670) Introduces a SystemProperty security#security.datafile.loadurls.enable which can be set to true to allow loading of urls in the XML import.
This commit is contained in:
committed by
Michael Brohl
parent
c42d580304
commit
20ccb4dcfd
@@ -2125,6 +2125,10 @@
|
||||
<value xml:lang="zh">错误:读取文件名 ${filename}:${errorString}</value>
|
||||
<value xml:lang="zh-TW">錯誤:讀取檔案名 ${filename}:${errorString}</value>
|
||||
</property>
|
||||
<property key="WebtoolsErrorDatafileLoadUrlNotEnabled">
|
||||
<value xml:lang="en">ERROR: For security reason HTTP URLs are not accepted, see OFBIZ-12304. Rather load your data from a file or set SystemProperty security.datafile.loadurls.enable = true</value>
|
||||
<value xml:lang="de">FEHLER: Aus Sicherheitsgründen wird das Laden von HTTP Urls nicht erlaubt. Laden Sie die Daten über eine Datei oder setzen Sie die SystemProperty security.datafile.loadurls.enable = true.</value>
|
||||
</property>
|
||||
<property key="WebtoolsErrorReadingTemplateFile">
|
||||
<value xml:lang="en">ERROR: reading template file ${filename}: ${errorString}</value>
|
||||
<value xml:lang="fr">ERREUR : lors de la lecture du fichier modèle ${filename}, une exception c'est levée (${errorString})</value>
|
||||
|
||||
@@ -84,6 +84,7 @@ import org.apache.ofbiz.entity.util.EntityDataLoader;
|
||||
import org.apache.ofbiz.entity.util.EntityListIterator;
|
||||
import org.apache.ofbiz.entity.util.EntityQuery;
|
||||
import org.apache.ofbiz.entity.util.EntitySaxReader;
|
||||
import org.apache.ofbiz.entity.util.EntityUtilProperties;
|
||||
import org.apache.ofbiz.entityext.EntityGroupUtil;
|
||||
import org.apache.ofbiz.security.Security;
|
||||
import org.apache.ofbiz.service.DispatchContext;
|
||||
@@ -108,6 +109,7 @@ public class WebToolsServices {
|
||||
public static Map<String, Object> entityImport(DispatchContext dctx, Map<String, ? extends Object> context) {
|
||||
GenericValue userLogin = (GenericValue) context.get("userLogin");
|
||||
LocalDispatcher dispatcher = dctx.getDispatcher();
|
||||
Delegator delegator = dctx.getDelegator();
|
||||
Locale locale = (Locale) context.get("locale");
|
||||
List<String> messages = new LinkedList<>();
|
||||
|
||||
@@ -145,10 +147,11 @@ public class WebToolsServices {
|
||||
// #############################
|
||||
// FM Template
|
||||
// #############################
|
||||
if (UtilValidate.urlInString(fulltext)) {
|
||||
if (UtilValidate.urlInString(fulltext)
|
||||
&& !"true".equals(EntityUtilProperties.getPropertyValue("security", "security.datafile.loadurls.enable", "false", delegator))) {
|
||||
Debug.logError("For security reason HTTP URLs are not accepted, see OFBIZ-12304", MODULE);
|
||||
Debug.logInfo("Rather load your data from a file", MODULE);
|
||||
return null;
|
||||
Debug.logInfo("Rather load your data from a file or set SystemProperty security.datafile.loadurls.enable = true", MODULE);
|
||||
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsErrorDatafileLoadUrlNotEnabled", locale));
|
||||
}
|
||||
if (UtilValidate.isNotEmpty(fmfilename) && (UtilValidate.isNotEmpty(fulltext) || url != null)) {
|
||||
File fmFile = new File(fmfilename);
|
||||
|
||||
Reference in New Issue
Block a user