From d4949327efa15b492cab1bef3fe074290a328a17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 21 Feb 2014 15:43:14 +0100 Subject: [add] HTML Purifier added to clean code --- .../htmlpurifier/HTMLPurifier/Token/Comment.php | 38 ++++++++++++ .../htmlpurifier/HTMLPurifier/Token/Empty.php | 15 +++++ .../htmlpurifier/HTMLPurifier/Token/End.php | 24 ++++++++ .../htmlpurifier/HTMLPurifier/Token/Start.php | 10 ++++ .../htmlpurifier/HTMLPurifier/Token/Tag.php | 68 ++++++++++++++++++++++ .../htmlpurifier/HTMLPurifier/Token/Text.php | 53 +++++++++++++++++ 6 files changed, 208 insertions(+) create mode 100644 inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Comment.php create mode 100644 inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Empty.php create mode 100644 inc/3rdparty/htmlpurifier/HTMLPurifier/Token/End.php create mode 100644 inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Start.php create mode 100644 inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Tag.php create mode 100644 inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Text.php (limited to 'inc/3rdparty/htmlpurifier/HTMLPurifier/Token') diff --git a/inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Comment.php b/inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Comment.php new file mode 100644 index 00000000..3fd273b1 --- /dev/null +++ b/inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Comment.php @@ -0,0 +1,38 @@ +data = $data; + $this->line = $line; + $this->col = $col; + } + + public function toNode() { + return new HTMLPurifier_Node_Comment($this->data, $this->line, $this->col); + } +} + +// vim: et sw=4 sts=4 diff --git a/inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Empty.php b/inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Empty.php new file mode 100644 index 00000000..bd35024a --- /dev/null +++ b/inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Empty.php @@ -0,0 +1,15 @@ +empty = true; + return $n; + } +} + +// vim: et sw=4 sts=4 diff --git a/inc/3rdparty/htmlpurifier/HTMLPurifier/Token/End.php b/inc/3rdparty/htmlpurifier/HTMLPurifier/Token/End.php new file mode 100644 index 00000000..99c34e75 --- /dev/null +++ b/inc/3rdparty/htmlpurifier/HTMLPurifier/Token/End.php @@ -0,0 +1,24 @@ +toNode not supported!"); + } +} + +// vim: et sw=4 sts=4 diff --git a/inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Start.php b/inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Start.php new file mode 100644 index 00000000..574745b6 --- /dev/null +++ b/inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Start.php @@ -0,0 +1,10 @@ +!empty($obj->is_tag) + * without having to use a function call is_a(). + * @type bool + */ + public $is_tag = true; + + /** + * The lower-case name of the tag, like 'a', 'b' or 'blockquote'. + * + * @note Strictly speaking, XML tags are case sensitive, so we shouldn't + * be lower-casing them, but these tokens cater to HTML tags, which are + * insensitive. + * @type string + */ + public $name; + + /** + * Associative array of the tag's attributes. + * @type array + */ + public $attr = array(); + + /** + * Non-overloaded constructor, which lower-cases passed tag name. + * + * @param string $name String name. + * @param array $attr Associative array of attributes. + * @param int $line + * @param int $col + * @param array $armor + */ + public function __construct($name, $attr = array(), $line = null, $col = null, $armor = array()) + { + $this->name = ctype_lower($name) ? $name : strtolower($name); + foreach ($attr as $key => $value) { + // normalization only necessary when key is not lowercase + if (!ctype_lower($key)) { + $new_key = strtolower($key); + if (!isset($attr[$new_key])) { + $attr[$new_key] = $attr[$key]; + } + if ($new_key !== $key) { + unset($attr[$key]); + } + } + } + $this->attr = $attr; + $this->line = $line; + $this->col = $col; + $this->armor = $armor; + } + + public function toNode() { + return new HTMLPurifier_Node_Element($this->name, $this->attr, $this->line, $this->col, $this->armor); + } +} + +// vim: et sw=4 sts=4 diff --git a/inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Text.php b/inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Text.php new file mode 100644 index 00000000..ff45125a --- /dev/null +++ b/inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Text.php @@ -0,0 +1,53 @@ +data = $data; + $this->is_whitespace = ctype_space($data); + $this->line = $line; + $this->col = $col; + } + + public function toNode() { + return new HTMLPurifier_Node_Text($this->data, $this->is_whitespace, $this->line, $this->col); + } +} + +// vim: et sw=4 sts=4 -- cgit v1.2.3