aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/3rdparty/htmlpurifier/HTMLPurifier/Token
diff options
context:
space:
mode:
Diffstat (limited to 'inc/3rdparty/htmlpurifier/HTMLPurifier/Token')
-rw-r--r--inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Comment.php38
-rw-r--r--inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Empty.php15
-rw-r--r--inc/3rdparty/htmlpurifier/HTMLPurifier/Token/End.php24
-rw-r--r--inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Start.php10
-rw-r--r--inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Tag.php68
-rw-r--r--inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Text.php53
6 files changed, 208 insertions, 0 deletions
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 @@
1<?php
2
3/**
4 * Concrete comment token class. Generally will be ignored.
5 */
6class HTMLPurifier_Token_Comment extends HTMLPurifier_Token
7{
8 /**
9 * Character data within comment.
10 * @type string
11 */
12 public $data;
13
14 /**
15 * @type bool
16 */
17 public $is_whitespace = true;
18
19 /**
20 * Transparent constructor.
21 *
22 * @param string $data String comment data.
23 * @param int $line
24 * @param int $col
25 */
26 public function __construct($data, $line = null, $col = null)
27 {
28 $this->data = $data;
29 $this->line = $line;
30 $this->col = $col;
31 }
32
33 public function toNode() {
34 return new HTMLPurifier_Node_Comment($this->data, $this->line, $this->col);
35 }
36}
37
38// 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 @@
1<?php
2
3/**
4 * Concrete empty token class.
5 */
6class HTMLPurifier_Token_Empty extends HTMLPurifier_Token_Tag
7{
8 public function toNode() {
9 $n = parent::toNode();
10 $n->empty = true;
11 return $n;
12 }
13}
14
15// 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 @@
1<?php
2
3/**
4 * Concrete end token class.
5 *
6 * @warning This class accepts attributes even though end tags cannot. This
7 * is for optimization reasons, as under normal circumstances, the Lexers
8 * do not pass attributes.
9 */
10class HTMLPurifier_Token_End extends HTMLPurifier_Token_Tag
11{
12 /**
13 * Token that started this node.
14 * Added by MakeWellFormed. Please do not edit this!
15 * @type HTMLPurifier_Token
16 */
17 public $start;
18
19 public function toNode() {
20 throw new Exception("HTMLPurifier_Token_End->toNode not supported!");
21 }
22}
23
24// 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 @@
1<?php
2
3/**
4 * Concrete start token class.
5 */
6class HTMLPurifier_Token_Start extends HTMLPurifier_Token_Tag
7{
8}
9
10// vim: et sw=4 sts=4
diff --git a/inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Tag.php b/inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Tag.php
new file mode 100644
index 00000000..284e32ee
--- /dev/null
+++ b/inc/3rdparty/htmlpurifier/HTMLPurifier/Token/Tag.php
@@ -0,0 +1,68 @@
1<?php
2
3/**
4 * Abstract class of a tag token (start, end or empty), and its behavior.
5 */
6abstract class HTMLPurifier_Token_Tag extends HTMLPurifier_Token
7{
8 /**
9 * Static bool marker that indicates the class is a tag.
10 *
11 * This allows us to check objects with <tt>!empty($obj->is_tag)</tt>
12 * without having to use a function call <tt>is_a()</tt>.
13 * @type bool
14 */
15 public $is_tag = true;
16
17 /**
18 * The lower-case name of the tag, like 'a', 'b' or 'blockquote'.
19 *
20 * @note Strictly speaking, XML tags are case sensitive, so we shouldn't
21 * be lower-casing them, but these tokens cater to HTML tags, which are
22 * insensitive.
23 * @type string
24 */
25 public $name;
26
27 /**
28 * Associative array of the tag's attributes.
29 * @type array
30 */
31 public $attr = array();
32
33 /**
34 * Non-overloaded constructor, which lower-cases passed tag name.
35 *
36 * @param string $name String name.
37 * @param array $attr Associative array of attributes.
38 * @param int $line
39 * @param int $col
40 * @param array $armor
41 */
42 public function __construct($name, $attr = array(), $line = null, $col = null, $armor = array())
43 {
44 $this->name = ctype_lower($name) ? $name : strtolower($name);
45 foreach ($attr as $key => $value) {
46 // normalization only necessary when key is not lowercase
47 if (!ctype_lower($key)) {
48 $new_key = strtolower($key);
49 if (!isset($attr[$new_key])) {
50 $attr[$new_key] = $attr[$key];
51 }
52 if ($new_key !== $key) {
53 unset($attr[$key]);
54 }
55 }
56 }
57 $this->attr = $attr;
58 $this->line = $line;
59 $this->col = $col;
60 $this->armor = $armor;
61 }
62
63 public function toNode() {
64 return new HTMLPurifier_Node_Element($this->name, $this->attr, $this->line, $this->col, $this->armor);
65 }
66}
67
68// 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 @@
1<?php
2
3/**
4 * Concrete text token class.
5 *
6 * Text tokens comprise of regular parsed character data (PCDATA) and raw
7 * character data (from the CDATA sections). Internally, their
8 * data is parsed with all entities expanded. Surprisingly, the text token
9 * does have a "tag name" called #PCDATA, which is how the DTD represents it
10 * in permissible child nodes.
11 */
12class HTMLPurifier_Token_Text extends HTMLPurifier_Token
13{
14
15 /**
16 * @type string
17 */
18 public $name = '#PCDATA';
19 /**< PCDATA tag name compatible with DTD. */
20
21 /**
22 * @type string
23 */
24 public $data;
25 /**< Parsed character data of text. */
26
27 /**
28 * @type bool
29 */
30 public $is_whitespace;
31
32 /**< Bool indicating if node is whitespace. */
33
34 /**
35 * Constructor, accepts data and determines if it is whitespace.
36 * @param string $data String parsed character data.
37 * @param int $line
38 * @param int $col
39 */
40 public function __construct($data, $line = null, $col = null)
41 {
42 $this->data = $data;
43 $this->is_whitespace = ctype_space($data);
44 $this->line = $line;
45 $this->col = $col;
46 }
47
48 public function toNode() {
49 return new HTMLPurifier_Node_Text($this->data, $this->is_whitespace, $this->line, $this->col);
50 }
51}
52
53// vim: et sw=4 sts=4