aboutsummaryrefslogtreecommitdiff
path: root/mod/htmlawed/start.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-07-01 14:55:58 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-07-01 14:55:58 +0000
commite8b29ab788547534deb8a0a946b5f77700a9f7a9 (patch)
tree790ef42993d568b12f460d108e36d142e0efa80c /mod/htmlawed/start.php
parentd893a8fd0e1dca7d2ec40f4621733e30343f091f (diff)
downloadelgg-e8b29ab788547534deb8a0a946b5f77700a9f7a9.tar.gz
elgg-e8b29ab788547534deb8a0a946b5f77700a9f7a9.tar.bz2
Refs #1086: Added htmLawed plugin as replacement for kses.
git-svn-id: https://code.elgg.org/elgg/trunk@3375 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/htmlawed/start.php')
-rw-r--r--mod/htmlawed/start.php66
1 files changed, 66 insertions, 0 deletions
diff --git a/mod/htmlawed/start.php b/mod/htmlawed/start.php
new file mode 100644
index 000000000..31ba15288
--- /dev/null
+++ b/mod/htmlawed/start.php
@@ -0,0 +1,66 @@
+<?php
+ /**
+ * Elgg htmLawed tag filtering.
+ *
+ * @package ElgghtmLawed
+ * @license http://www.gnu.org/licenses/gpl.html GNU Public License version 3
+ * @author Curverider Ltd
+ * @author Brett Profitt
+ * @copyright Curverider Ltd 2008-2009
+ * @link http://elgg.com/
+ */
+
+ /**
+ * Initialise plugin
+ *
+ */
+ function htmlawed_init()
+ {
+ /** For now declare allowed tags and protocols here, TODO: Make this configurable */
+ global $CONFIG;
+ $CONFIG->htmlawed_config = array(
+ // seems to handle about everything we need.
+ 'safe' => true,
+ 'deny_attribute' => 'style',
+ 'schemes' => '*:http,https,ftp,news,mailto,rtsp,teamspeak,gopher,mms,callto'
+ );
+
+ register_plugin_hook('validate', 'input', 'htmlawed_filter_tags', 1);
+ }
+
+ /**
+ * htmLawed filtering of tags, called on a plugin hook
+ *
+ * @param mixed $var Variable to filter
+ * @return mixed
+ */
+ function htmlawed_filter_tags($hook, $entity_type, $returnvalue, $params)
+ {
+ $return = $returnvalue;
+ $var = $returnvalue;
+
+ if (@include_once(dirname(__FILE__) . "/vendors/htmLawed/htmLawed.php")) {
+
+ global $CONFIG;
+
+ $htmlawed_config = $CONFIG->htmlawed_config;
+
+ if (!is_array($var)) {
+ $return = "";
+ $return = htmLawed($var, $htmlawed_config);
+ } else {
+ $return = array();
+
+ foreach($var as $key => $el) {
+ $return[$key] = htmLawed($var, $htmlawed_config);
+ }
+ }
+ }
+
+ return $return;
+ }
+
+
+ register_elgg_event_handler('init','system','htmlawed_init');
+
+?>