Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Stokes <mogurijin@gmail.com>2012-07-23 02:58:12 +0400
committerMitchell Stokes <mogurijin@gmail.com>2012-07-23 02:58:12 +0400
commit7fb85e1fb7a9ceb53b4477402a8536ae07cdc950 (patch)
treed837ca824a300773ea4a57377152bef2a756ef5c /source/gameengine
parentdf3f3dff3b5c4261b9541998029c248ead5efb2f (diff)
BGE LibLoad: Allow the user to disable loading text datablocks if they want to attempt to increase security by not loading potential Python scripts.
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.cpp7
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.h1
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp10
3 files changed, 10 insertions, 8 deletions
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
index 3961e6554a7..651c1a70f45 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
@@ -988,8 +988,7 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha
load_datablocks(main_newlib, bpy_openlib, path, idcode);
- if (idcode==ID_SCE) {
- /* assume we want text blocks too */
+ if (idcode==ID_SCE && options & LIB_LOAD_LOAD_SCRIPTS) {
load_datablocks(main_newlib, bpy_openlib, path, ID_TXT);
}
@@ -1045,8 +1044,8 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha
}
/* Handle any text datablocks */
-
- addImportMain(main_newlib);
+ if (options & LIB_LOAD_LOAD_SCRIPTS)
+ addImportMain(main_newlib);
/* Now handle all the actions */
if (options & LIB_LOAD_LOAD_ACTIONS) {
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h
index 906e3fed111..b51c2f21ca7 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.h
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h
@@ -182,6 +182,7 @@ public:
{
LIB_LOAD_LOAD_ACTIONS = 1,
LIB_LOAD_VERBOSE = 2,
+ LIB_LOAD_LOAD_SCRIPTS = 4,
};
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 823363dfd11..536b32cbd77 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -676,12 +676,12 @@ static PyObject *gLibLoad(PyObject*, PyObject* args, PyObject* kwds)
char *err_str= NULL;
short options=0;
- int load_actions=0, verbose=0;
+ int load_actions=0, verbose=0, load_scripts=1;
- static const char *kwlist[] = {"path", "group", "buffer", "load_actions", "verbose", NULL};
+ static const char *kwlist[] = {"path", "group", "buffer", "load_actions", "verbose", "load_scripts", NULL};
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "ss|y*ii:LibLoad", const_cast<char**>(kwlist),
- &path, &group, &py_buffer, &load_actions, &verbose))
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "ss|y*iii:LibLoad", const_cast<char**>(kwlist),
+ &path, &group, &py_buffer, &load_actions, &verbose, &load_scripts))
return NULL;
/* setup options */
@@ -689,6 +689,8 @@ static PyObject *gLibLoad(PyObject*, PyObject* args, PyObject* kwds)
options |= KX_BlenderSceneConverter::LIB_LOAD_LOAD_ACTIONS;
if (verbose != 0)
options |= KX_BlenderSceneConverter::LIB_LOAD_VERBOSE;
+ if (load_scripts != 0)
+ options |= KX_BlenderSceneConverter::LIB_LOAD_LOAD_SCRIPTS;
if (!py_buffer.buf)
{