1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<?php
/**
* Elgg htmLawed tag filtering.
*
* @package ElgghtmLawed
* @author Curverider Ltd
* @author Brett Profitt
* @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' => 'class',
'schemes' => '*: http,https,ftp,news,mailto,rtsp,teamspeak,gopher,mms,callto;'
. 'style: color,cursor,text-align,font-size,font-weight,font-style,border,margin,padding,float'
);
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($el, $htmlawed_config);
}
}
}
return $return;
}
register_elgg_event_handler('init','system','htmlawed_init');
?>
|