summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortekimaki <will@tekimaki.com>2011-01-25 16:57:06 -0500
committertekimaki <will@tekimaki.com>2011-01-25 16:57:06 -0500
commit2d888e347f77ee6dbd6306a93630bb6d17343c24 (patch)
treed7cbec9cc2e8d7d271903d03410ab502d25277a8
parentbd03375fa2a32853219ddf4cab53604cb7e1035b (diff)
downloadutil-2d888e347f77ee6dbd6306a93630bb6d17343c24.tar.gz
util-2d888e347f77ee6dbd6306a93630bb6d17343c24.tar.bz2
util-2d888e347f77ee6dbd6306a93630bb6d17343c24.zip
add htmlpurifier iframe filter to allow any sort of non-sense
-rw-r--r--htmlpure/Filter/SafeIframe.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/htmlpure/Filter/SafeIframe.php b/htmlpure/Filter/SafeIframe.php
new file mode 100644
index 0000000..370c89c
--- /dev/null
+++ b/htmlpure/Filter/SafeIframe.php
@@ -0,0 +1,20 @@
+<?php
+
+class HTMLPurifier_Filter_SafeIframe extends HTMLPurifier_Filter
+{
+ public $name = 'SafeIframe';
+
+ public function preFilter($html, $config, $context) {
+ return preg_replace("/iframe/", "img class=\"SafeIframe\" ", preg_replace("/<\/iframe>/", "", $html));
+ }
+
+ public function postFilter($html, $config, $context) {
+ $post_regex = '#<img class="SafeIframe" ([^>]+)>#';
+ return preg_replace_callback($post_regex, array($this, 'postFilterCallback'), $html);
+ }
+
+ protected function postFilterCallback($matches) {
+ return '<iframe '.$matches[1].'></iframe>';
+ }
+}
+