summaryrefslogtreecommitdiff
path: root/src/ste/STEStandardLibrary.php
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2015-04-13 22:35:27 +0200
committerKevin Chabowski <kevin@kch42.de>2015-04-13 22:35:27 +0200
commitf744b3227b116d4f7ccd7c71f8b8498ebf86d85f (patch)
tree87a2ea0047c7587375986d3b1a2a31c05e8d36ce /src/ste/STEStandardLibrary.php
parent6d1c13b05d16e89268403860e47743455ea0a2ff (diff)
downloadste-f744b3227b116d4f7ccd7c71f8b8498ebf86d85f.tar.gz
ste-f744b3227b116d4f7ccd7c71f8b8498ebf86d85f.tar.bz2
ste-f744b3227b116d4f7ccd7c71f8b8498ebf86d85f.zip
Implemented autoescaping
Still needs some cleanup and documentation.
Diffstat (limited to 'src/ste/STEStandardLibrary.php')
-rw-r--r--src/ste/STEStandardLibrary.php18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/ste/STEStandardLibrary.php b/src/ste/STEStandardLibrary.php
index 915b699..68ba06a 100644
--- a/src/ste/STEStandardLibrary.php
+++ b/src/ste/STEStandardLibrary.php
@@ -12,13 +12,27 @@ class STEStandardLibrary {
}
static public function escape($ste, $params, $sub) {
+ $content = $ste->eval_sub_with_escaping($sub, STECore::ESCAPE_NONE);
+
if($ste->evalbool(@$params["lines"])) {
- return nl2br(htmlspecialchars(str_replace("\r\n", "\n", $sub($ste))));
+ return nl2br(htmlspecialchars(str_replace("\r\n", "\n", $content)));
} else {
- return htmlspecialchars($sub($ste));
+ return htmlspecialchars($content);
}
}
+ static public function raw($ste, $params, $sub) {
+ return $ste->eval_sub_with_escaping($sub, STECore::ESCAPE_NONE);
+ }
+
+ static public function autoescape($ste, $params, $sub) {
+ if(empty($params["mode"])) {
+ throw new RuntimeError("Missing mode parameter in <ste:arraylen>.");
+ }
+
+ return $content = $ste->eval_sub_with_escaping($sub, $params['mode']);
+ }
+
static public function strlen($ste, $params, $sub) {
return strlen($sub($ste));
}