Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit f874906

Browse files
Merge remote-tracking branch 'origin/develop-6.7' into develop-7.0
Conflicts: engine/src/dispatch.cpp engine/src/execpt.cpp engine/src/execpt.h engine/src/externalv0.cpp engine/src/externalv1.cpp engine/src/funcs.cpp engine/src/funcs.h engine/src/handler.cpp engine/src/handler.h engine/src/hndlrlst.cpp engine/src/hndlrlst.h engine/src/srvcgi.cpp engine/src/variable.cpp
2 parents abc4c16 + 5987e66 commit f874906

23 files changed

+403
-269
lines changed

docs/notes/bugfix-15416.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Crash when building a SQLite query with out-of-bounds placeholders

docs/notes/bugfix-15432.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Filename of stack not properly handling tilde character

docs/notes/bugfix-9820.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# LiveCode Server provides no POST data when Content-Type is application/x-www-form-urlencoded; charset=<...>

engine/src/cmds.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,8 @@ void MCDo::exec_ctxt(MCExecContext& ctxt)
487487
// MW-2013-11-15: [[ Bug 11277 ]] If no handler, then evaluate in context of the
488488
// server script object.
489489
Exec_stat stat;
490-
if (ep . gethandler() != nil)
491-
stat = ep.gethandler()->doscript(*epptr, line, pos);
492-
else
493-
stat = ep.gethlist()->doscript(*epptr, line, pos);
490+
stat = ep.doscript(*epptr, line, pos);
491+
494492
if (added)
495493
MCnexecutioncontexts--;
496494
return stat;
@@ -3026,4 +3024,4 @@ void MCAssertCmd::exec_ctxt(MCExecContext& ctxt)
30263024
void MCAssertCmd::compile(MCSyntaxFactoryRef ctxt)
30273025
{
30283026

3029-
}
3027+
}

engine/src/cmdse.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,13 +1294,10 @@ void MCMessage::exec_ctxt(MCExecContext &ctxt)
12941294

12951295
// MW-2011-08-11: [[ Bug 9668 ]] Make sure we copy 'pdata' if we use it, since
12961296
// mptr (into which it points) only lasts as long as this method call.
1297-
// MW-2013-11-15: [[ Bug 11277 ]] If no handler, evaluate in the context of the
1298-
// server script object.
1297+
// MW-2013-11-15: [[ Bug 11277 ]] Refactor MCHandler::eval
12991298
Exec_stat t_stat;
1300-
if (ep.gethandler() != nil)
1301-
t_stat = ep . gethandler() -> eval(ep);
1302-
else
1303-
t_stat = ep . gethlist() -> eval(ep);
1299+
t_stat = ep . eval(ep);
1300+
13041301
if (t_stat == ES_NORMAL)
13051302
newparam->set_argument(ep);
13061303
else

engine/src/dispatch.cpp

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -962,28 +962,18 @@ IO_stat MCDispatch::doreadfile(MCStringRef p_openpath, MCStringRef p_name, IO_ha
962962

963963
IO_stat MCDispatch::loadfile(MCStringRef p_name, MCStack *&sptr)
964964
{
965-
IO_handle stream;
965+
IO_handle stream;
966966
MCAutoStringRef t_open_path;
967967

968968
bool t_found;
969969
t_found = false;
970970
if (!t_found)
971971
{
972972
if ((stream = MCS_open(p_name, kMCOpenFileModeRead, True, False, 0)) != NULL)
973-
{
974-
// This should probably use resolvepath().
975-
if (MCStringGetCharAtIndex(p_name, 0) != PATH_SEPARATOR
976-
&& MCStringGetCharAtIndex(p_name, 1) != ':')
977-
{
978-
MCAutoStringRef t_curpath;
979-
980-
/* UNCHECKED */ MCS_getcurdir(&t_curpath);
981-
/* UNCHECKED */ MCStringFormat(&t_open_path, "%@/%@", *t_curpath, p_name);
982-
}
983-
else
984-
t_open_path = p_name;
985-
986-
t_found = true;
973+
{
974+
// This should probably use resolvepath().
975+
// SN-2015-06-03: [[ Bug 15432 ]] Use resolvepath
976+
t_found = MCS_resolvepath(p_name, &t_open_path);
987977
}
988978
}
989979

@@ -998,7 +988,7 @@ IO_stat MCDispatch::loadfile(MCStringRef p_name, MCStack *&sptr)
998988
else
999989
t_leaf_name = p_name;
1000990
if ((stream = MCS_open(*t_leaf_name, kMCOpenFileModeRead, True, False, 0)) != NULL)
1001-
{
991+
{
1002992
MCAutoStringRef t_curpath;
1003993
/* UNCHECKED */ MCS_getcurdir(&t_curpath);
1004994
/* UNCHECKED */ MCStringFormat(&t_open_path, "%@/%@", *t_curpath, p_name);

engine/src/exec-debugging.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void MCDebuggingExecDebugDo(MCExecContext& ctxt, MCStringRef p_script, uinteger_
7878
MCExecContext *t_ctxt_ptr;
7979
t_ctxt_ptr = MCexecutioncontexts[MCdebugcontext];
8080

81-
t_ctxt_ptr->GetHandler()->doscript(*t_ctxt_ptr, p_script, p_line, p_pos);
81+
t_ctxt_ptr->doscript(*t_ctxt_ptr, p_script, p_line, p_pos);
8282

8383
// AL-2014-03-21: [[ Bug 11940 ]] Ensure the debug context is not permanently in a state of error.
8484
t_ctxt_ptr -> IgnoreLastError();

engine/src/exec-engine.cpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,11 @@ void MCEngineEvalParam(MCExecContext& ctxt, integer_t p_index, MCValueRef& r_val
444444
void MCEngineEvalParamCount(MCExecContext& ctxt, integer_t& r_count)
445445
{
446446
// MW-2013-11-15: [[ Bug 11277 ]] If we don't have a handler then 'the param'
447-
// makes no sense so just return 0.
448-
// PM-2014-04-14: [[Bug 12105]] Do this check to prevent crash in LC server
447+
// makes no sense so just return 0.
449448
if (ctxt.GetHandler() != nil)
450449
r_count = ctxt.GetHandler()->getnparams();
451450
else
452-
ctxt . LegacyThrow(EE_PARAMCOUNT_NOHANDLER);
451+
r_count = 0;
453452
}
454453

455454
void MCEngineEvalParams(MCExecContext& ctxt, MCStringRef& r_string)
@@ -650,10 +649,9 @@ void MCEngineEvalValue(MCExecContext& ctxt, MCStringRef p_script, MCValueRef& r_
650649
return;
651650
}
652651

653-
if (ctxt.GetHandler() != nil)
654-
ctxt.GetHandler()->eval(ctxt, p_script, r_value);
655-
else
656-
ctxt.GetHandlerList()->eval(ctxt, p_script, r_value);
652+
// SN-2015-06-03: [[ Bug 11277 ]] MCHandler::eval refactored
653+
ctxt.eval(ctxt, p_script, r_value);
654+
657655
if (ctxt.HasError())
658656
ctxt.LegacyThrow(EE_VALUE_ERROR, p_script);
659657
}
@@ -851,10 +849,8 @@ void MCEngineExecDo(MCExecContext& ctxt, MCStringRef p_script, int p_line, int p
851849
added = True;
852850
}
853851

854-
if (ctxt.GetHandler() != nil)
855-
ctxt.GetHandler() -> doscript(ctxt, p_script, p_line, p_pos);
856-
else
857-
ctxt.GetHandlerList() -> doscript(ctxt, p_script, p_line, p_pos);
852+
// SN-2015-06-03: [[ Bug 11277 ]] MCHandler::doscript refactored
853+
ctxt.doscript(ctxt, p_script, p_line, p_pos);
858854

859855
if (added)
860856
MCnexecutioncontexts--;
@@ -880,10 +876,8 @@ void MCEngineExecDoInCaller(MCExecContext& ctxt, MCStringRef p_script, int p_lin
880876

881877
MCExecContext *caller = MCexecutioncontexts[MCnexecutioncontexts - 2];
882878

883-
if (caller -> GetHandler() != nil)
884-
caller -> GetHandler() -> doscript(*caller, p_script, p_line, p_pos);
885-
else
886-
caller -> GetHandlerList() -> doscript(*caller, p_script, p_line, p_pos);
879+
// SN-2015-06-03: [[ Bug 11277 ]] MCHandler::doscript refactored
880+
caller -> doscript(*caller, p_script, p_line, p_pos);
887881

888882
if (added)
889883
MCnexecutioncontexts--;
@@ -1305,8 +1299,9 @@ static void MCEngineSplitScriptIntoMessageAndParameters(MCExecContext& ctxt, MCS
13051299

13061300
// MW-2011-08-11: [[ Bug 9668 ]] Make sure we copy 'pdata' if we use it, since
13071301
// mptr (into which it points) only lasts as long as this method call.
1302+
// SN-2015-06-03: [[ Bug 11277 ]] MCHandler::eval_ctxt refactored
13081303
MCExecValue t_value;
1309-
ctxt . GetHandler() -> eval_ctxt(ctxt, *t_expression, t_value);
1304+
ctxt . eval_ctxt(ctxt, *t_expression, t_value);
13101305
if (!ctxt.HasError())
13111306
newparam->set_exec_argument(ctxt, t_value);
13121307
else
@@ -1995,4 +1990,4 @@ void MCEngineGetEditionType(MCExecContext& ctxt, MCStringRef& r_edition)
19951990
return;
19961991

19971992
ctxt . Throw();
1998-
}
1993+
}

engine/src/exec-strings.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,17 +1393,14 @@ bool MCStringsMerge(MCExecContext& ctxt, MCStringRef p_format, MCStringRef& r_st
13931393
MCerrorlock++;
13941394
if (t_is_expression)
13951395
{
1396-
if (ctxt . GetHandler() != nil)
1397-
ctxt.GetHandler()->eval(t_ctxt, *t_expression, &t_value);
1398-
else
1399-
ctxt.GetHandlerList()->eval(t_ctxt, *t_expression, &t_value);
1396+
// SN-2015-06-03: [[ Bug 11277 ]] MCHandler::eval refactored
1397+
ctxt.eval(t_ctxt, *t_expression, &t_value);
14001398
}
14011399
else
1402-
{
1403-
if (ctxt . GetHandler() != nil)
1404-
ctxt.GetHandler()->doscript(t_ctxt, *t_expression);
1405-
else
1406-
ctxt.GetHandlerList()->doscript(t_ctxt, *t_expression);
1400+
{
1401+
// SN-2015-06-03: [[ Bug 11277 ]] MCHandler::doscript refactored
1402+
ctxt.doscript(t_ctxt, *t_expression, 0, 0);
1403+
14071404
t_value = MCresult->getvalueref();
14081405
// SN-2014-08-11: [[ Bug 13139 ]] The result must be emptied after a doscript()
14091406
ctxt . SetTheResultToEmpty();

engine/src/exec.cpp

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
3838
#include "debug.h"
3939
#include "param.h"
4040

41+
#include "statemnt.h"
42+
#include "license.h"
43+
#include "scriptpt.h"
44+
#include "newobj.h"
45+
4146
// SN-2014-09-05: [[ Bug 13378 ]] Include the definition of MCServerScript
4247
#ifdef _SERVER
4348
#include "srvscript.h"
@@ -1222,6 +1227,168 @@ void MCExecContext::SetTheResultToBool(bool p_bool)
12221227
MCresult -> sets(MCU_btos(p_bool));
12231228
}
12241229

1230+
// SN-2015-06-03: [[ Bug 11277 ]] Refactor MCExecPoint update
1231+
void MCExecContext::deletestatements(MCStatement* p_statements)
1232+
{
1233+
while (p_statements != NULL)
1234+
{
1235+
MCStatement *tsptr = p_statements;
1236+
p_statements = p_statements->getnext();
1237+
delete tsptr;
1238+
}
1239+
}
1240+
1241+
void MCExecContext::eval(MCExecContext &ctxt, MCStringRef p_expression, MCValueRef &r_value)
1242+
{
1243+
MCScriptPoint sp(ctxt, p_expression);
1244+
// SN-2015-06-03: [[ Bug 11277 ]] When we are out of handler, then it simply
1245+
// sets the ScriptPoint handler to NULL (same as post-constructor state).
1246+
sp.sethandler(ctxt . GetHandler());
1247+
MCExpression *exp = NULL;
1248+
Symbol_type type;
1249+
1250+
if (sp.parseexp(False, True, &exp) == PS_NORMAL && sp.next(type) == PS_EOF)
1251+
ctxt . EvalExprAsValueRef(exp, EE_HANDLER_BADEXP, r_value);
1252+
else
1253+
ctxt . Throw();
1254+
1255+
delete exp;
1256+
}
1257+
1258+
void MCExecContext::eval_ctxt(MCExecContext &ctxt, MCStringRef p_expression, MCExecValue& r_value)
1259+
{
1260+
MCScriptPoint sp(ctxt, p_expression);
1261+
// SN-2015-06-03: [[ Bug 11277 ]] When we are out of handler, then it simply
1262+
// sets the ScriptPoint handler to NULL (same as post-constructor state).
1263+
sp.sethandler(ctxt . GetHandler());
1264+
MCExpression *exp = NULL;
1265+
Symbol_type type;
1266+
1267+
if (sp.parseexp(False, True, &exp) == PS_NORMAL && sp.next(type) == PS_EOF)
1268+
ctxt . EvaluateExpression(exp, EE_HANDLER_BADEXP, r_value);
1269+
else
1270+
ctxt . Throw();
1271+
1272+
delete exp;
1273+
}
1274+
1275+
void MCExecContext::doscript(MCExecContext &ctxt, MCStringRef p_script, uinteger_t p_line, uinteger_t p_pos)
1276+
{
1277+
MCScriptPoint sp(ctxt, p_script);
1278+
MCStatement *curstatement = NULL;
1279+
MCStatement *statements = NULL;
1280+
MCStatement *newstatement = NULL;
1281+
Symbol_type type;
1282+
const LT *te;
1283+
Exec_stat stat = ES_NORMAL;
1284+
Boolean oldexplicit = MCexplicitvariables;
1285+
MCexplicitvariables = False;
1286+
uint4 count = 0;
1287+
sp.setline(p_line - 1);
1288+
while (stat == ES_NORMAL)
1289+
{
1290+
switch (sp.next(type))
1291+
{
1292+
case PS_NORMAL:
1293+
if (type == ST_ID)
1294+
if (sp.lookup(SP_COMMAND, te) != PS_NORMAL)
1295+
newstatement = new MCComref(sp.gettoken_nameref());
1296+
else
1297+
{
1298+
if (te->type != TT_STATEMENT)
1299+
{
1300+
MCeerror->add(EE_DO_NOTCOMMAND, p_line, p_pos, sp.gettoken_stringref());
1301+
stat = ES_ERROR;
1302+
}
1303+
else
1304+
newstatement = MCN_new_statement(te->which);
1305+
}
1306+
else
1307+
{
1308+
MCeerror->add(EE_DO_NOCOMMAND, p_line, p_pos, sp.gettoken_stringref());
1309+
stat = ES_ERROR;
1310+
}
1311+
if (stat == ES_NORMAL)
1312+
{
1313+
if (curstatement == NULL)
1314+
statements = curstatement = newstatement;
1315+
else
1316+
{
1317+
curstatement->setnext(newstatement);
1318+
curstatement = newstatement;
1319+
}
1320+
if (curstatement->parse(sp) != PS_NORMAL)
1321+
{
1322+
MCeerror->add(EE_DO_BADCOMMAND, p_line, p_pos, p_script);
1323+
stat = ES_ERROR;
1324+
}
1325+
count += curstatement->linecount();
1326+
}
1327+
break;
1328+
case PS_EOL:
1329+
if (sp.skip_eol() != PS_NORMAL)
1330+
{
1331+
MCeerror->add(EE_DO_BADLINE, p_line, p_pos, p_script);
1332+
stat = ES_ERROR;
1333+
}
1334+
break;
1335+
case PS_EOF:
1336+
stat = ES_PASS;
1337+
break;
1338+
default:
1339+
stat = ES_ERROR;
1340+
}
1341+
}
1342+
MCexplicitvariables = oldexplicit;
1343+
1344+
if (MClicenseparameters . do_limit > 0 && count >= MClicenseparameters . do_limit)
1345+
{
1346+
MCeerror -> add(EE_DO_NOTLICENSED, p_line, p_pos, p_script);
1347+
stat = ES_ERROR;
1348+
}
1349+
1350+
if (stat == ES_ERROR)
1351+
{
1352+
deletestatements(statements);
1353+
ctxt.Throw();
1354+
return;
1355+
}
1356+
1357+
MCExecContext ctxt2(ctxt);
1358+
while (statements != NULL)
1359+
{
1360+
statements->exec_ctxt(ctxt2);
1361+
Exec_stat stat = ctxt2 . GetExecStat();
1362+
if (stat == ES_ERROR)
1363+
{
1364+
deletestatements(statements);
1365+
MCeerror->add(EE_DO_BADEXEC, p_line, p_pos, p_script);
1366+
ctxt.Throw();
1367+
return;
1368+
}
1369+
if (MCexitall || stat != ES_NORMAL)
1370+
{
1371+
deletestatements(statements);
1372+
if (stat == ES_ERROR)
1373+
ctxt.Throw();
1374+
return;
1375+
}
1376+
else
1377+
{
1378+
MCStatement *tsptr = statements;
1379+
statements = statements->getnext();
1380+
delete tsptr;
1381+
}
1382+
}
1383+
if (MCscreen->abortkey())
1384+
{
1385+
MCeerror->add(EE_DO_ABORT, p_line, p_pos);
1386+
ctxt.Throw();
1387+
return;
1388+
}
1389+
return;
1390+
}
1391+
12251392
////////////////////////////////////////////////////////////////////////////////
12261393

12271394
static bool MCPropertyFormatUIntList(uinteger_t *p_list, uindex_t p_count, char_t p_delimiter, MCStringRef& r_string)

0 commit comments

Comments
 (0)