Skip to content

Commit

Permalink
Fix to issue #1348: add in a supported list to forbid trig functions …
Browse files Browse the repository at this point in the history
…in student input.
  • Loading branch information
sangwinc committed Jan 2, 2025
1 parent 2f61bf6 commit 629f2ef
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/en/Authoring/Inputs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ If you wish to forbid commas, then escape it with a backslash.
There are groups of common keywords which you can forbid simply as

* `[[BASIC-ALGEBRA]]` common algebraic operations such as `simplify`, `factor`, `expand`, `solve`, etc.
* `[[BASIC-TRIG]]` names of all the trig and hyperbolic trig functions and their inverses, e.g. `sin`, `asin`, `sinh`, `asinh`, etc.
* `[[BASIC-CALCULUS]]` common calculus operations such as `int`, `diff`, `taylor`, etc.
* `[[BASIC-MATRIX]]` common matrix operations such as `transpose`, `invert`, `charpoly`, etc.

Expand Down
7 changes: 7 additions & 0 deletions stack/cas/cassecurity.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ class stack_cas_security {
'trigrat' => true, 'trigreduce' => true, 'trigsign' => true,
'trigsimp' => true, 'truncate' => true, 'decimalplaces' => true, 'simplify' => true,
],
'[[basic-trig]]' => [
'sin' => true, 'cos' => true, 'tan' => true, 'sec' => true, 'csc' => true, 'cot' => true,
'asin' => true, 'acos' => true, 'atan' => true, 'asec' => true, 'acsc' => true, 'acot' => true,
'atan2' => true,
'sinh' => true, 'cosh' => true, 'tanh' => true, 'sech' => true, 'csch' => true, 'coth' => true,
'asinh' => true, 'acosh' => true, 'atanh' => true, 'asech' => true, 'acsch' => true, 'acoth' => true,
],
'[[basic-calculus]]' => [
'defint' => true, 'diff' => true, 'int' => true, 'integrate' => true,
'limit' => true, 'partial' => true, 'desolve' => true, 'express' => true, 'taylor' => true,
Expand Down
1 change: 1 addition & 0 deletions tests/ast_container_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ public function test_check_external_forbidden_words_literal(): void {
['[x,y,z]', 'b,\,,c', false],
['diff(x^2,x)', '[[BASIC-CALCULUS]]', false], // From lists.
['solve((x-6)^4,x)', '[[BASIC-ALGEBRA]]', false], // From lists.
['sin(A-B)', '[[BASIC-TRIG]]', false], // From lists.
];

foreach ($cases as $case) {
Expand Down

0 comments on commit 629f2ef

Please sign in to comment.