Skip to content
Snippets Groups Projects
Commit 4a7daccc authored by Chris Sangwin's avatar Chris Sangwin
Browse files

Code tidy.

parent d77ad0d6
No related branches found
No related tags found
No related merge requests found
......@@ -173,8 +173,9 @@ if ($only === false) {
'letToken' => stack_string('equiv_LET')));
}
$pipeline = stack_parsing_rule_factory::get_filter_pipeline(array('995_ev_modification', '996_call_modification', '998_security'),
array('998_security' => array('security' => 's'), '995_ev_modification' => ['flags' => false]), true);
$pipeline = stack_parsing_rule_factory::get_filter_pipeline(array('995_ev_modification',
'996_call_modification', '998_security'), array('998_security' => array('security' => 's'),
'995_ev_modification' => ['flags' => false]), true);
check_filter($freshast, $pipeline, new stack_cas_security(false), 'core + security(s)');
cli_heading('= core + security(t) + strict =');
......@@ -186,7 +187,8 @@ if ($only === false) {
'letToken' => stack_string('equiv_LET')));
}
$pipeline = stack_parsing_rule_factory::get_filter_pipeline(array('995_ev_modification', '996_call_modification', '998_security', '999_strict'),
$pipeline = stack_parsing_rule_factory::get_filter_pipeline(array('995_ev_modification', '996_call_modification',
'998_security', '999_strict'),
array('998_security' => array('security' => 't'), '995_ev_modification' => ['flags' => true]), true);
check_filter($freshast, $pipeline, new stack_cas_security(false), 'core + security(t) + strict');
}
......@@ -68,7 +68,8 @@ class stack_ast_filter_995_ev_modification implements stack_cas_astfilter_parame
if ($arg !== $payload) {
if ($arg instanceof MP_Identifier && $arg->value === 'simp') {
$simp = new MP_Boolean(true);
} else if ($arg instanceof MP_Operation && ($arg->op === ':' || $arg->op === '=') && $arg->lhs instanceof MP_Identifier && $arg->lhs->value === 'simp') {
} else if ($arg instanceof MP_Operation && ($arg->op === ':' || $arg->op === '=')
&& $arg->lhs instanceof MP_Identifier && $arg->lhs->value === 'simp') {
$simp = clone $arg->rhs;
}
}
......
......@@ -60,8 +60,9 @@ class stack_ast_filter_996_call_modification implements stack_cas_astfilter {
// If we have a complex mapping, i.e. a map function with
// the identifier coming from something else we rewrite it
// so that we can check the identifier using normal logic.
// apply(foo(),[...]) => block([_tmp],_tmp:foo(),apply(_tmp),[...]))
if ($node->name instanceof MP_Atom && isset($mapfuns[$node->name->value]) && count($node->arguments) > 0 && !($node->arguments[0] instanceof MP_Atom)) {
// For example apply(foo(),[...]) => block([_tmp],_tmp:foo(),apply(_tmp),[...])).
if ($node->name instanceof MP_Atom && isset($mapfuns[$node->name->value])
&& count($node->arguments) > 0 && !($node->arguments[0] instanceof MP_Atom)) {
$replacement = new MP_FunctionCall(new MP_Identifier('block'),
[
new MP_List([new MP_Identifier('_tmp_996')]),
......
......@@ -206,11 +206,8 @@ class maxima_replication_test extends qtype_stack_testcase {
}
public function test_iss844_mapping() {
/**
* Note that the old security rules forbid most of these,
* we will probably eventually relax those rules but they are
* still under review.
*/
// Note that the old security rules forbid most of these, we will probably
// eventually relax those rules but they are still under review.
$this->markTestSkipped('This works if we relax the security settings. If interested disable filter 998.');
$code = 'simp:true;';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment