summaryrefslogtreecommitdiff
path: root/src/ste/STECore.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/ste/STECore.php')
-rw-r--r--src/ste/STECore.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/ste/STECore.php b/src/ste/STECore.php
index 35a92d5..4637aaa 100644
--- a/src/ste/STECore.php
+++ b/src/ste/STECore.php
@@ -10,9 +10,13 @@ namespace kch42\ste;
* The Core of STE
*/
class STECore {
+ const ESCAPE_NONE = "none";
+ const ESCAPE_HTML = "html";
+
private $tags;
private $storage_access;
private $cur_tpl_dir;
+ public $escape_method = self::ESCAPE_NONE;
public $scope;
/*
@@ -101,6 +105,21 @@ class STECore {
}
}
+ public function autoescape($content) {
+ if ($this->escape_method == self::ESCAPE_HTML) {
+ return htmlspecialchars($content);
+ }
+ return $content;
+ }
+
+ public function eval_sub_with_escaping($sub, $method) {
+ $old_method = $this->escape_method;
+ $this->escape_method = $method;
+ $retval = $sub($this);
+ $this->escape_method = $old_method;
+ return $retval;
+ }
+
public function calc($expression) {
return Calc::calc($expression);
}