Completed
Branch scrutinizer (4d54e2)
by Fabio
15:49
created
framework/Collections/TAttributeCollection.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TAttributeCollection classes
4
- *
5
- * @author Qiang Xue <[email protected]>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Collections
10
- */
3
+	 * TAttributeCollection classes
4
+	 *
5
+	 * @author Qiang Xue <[email protected]>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
+	 * @package System.Collections
10
+	 */
11 11
 
12 12
 /**
13 13
  * Includes TMap class
Please login to merge, or discard this patch.
framework/Collections/TList.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * TList, TListIterator classes
4
- *
5
- * @author Qiang Xue <[email protected]>
6
- * @link https://github.com/pradosoft/prado
7
- * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
- * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
- * @package System.Collections
10
- */
3
+	 * TList, TListIterator classes
4
+	 *
5
+	 * @author Qiang Xue <[email protected]>
6
+	 * @link https://github.com/pradosoft/prado
7
+	 * @copyright Copyright &copy; 2005-2015 The PRADO Group
8
+	 * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
9
+	 * @package System.Collections
10
+	 */
11 11
 
12 12
 /**
13 13
  * TList class
Please login to merge, or discard this patch.
framework/3rdParty/WsdlGen/Wsdl.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Wsdl file.
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the BSD License.
7
- *
8
- * Copyright(c) 2005 by Marcus Nyeholt. All rights reserved.
9
- *
10
- * To contact the author write to {@link mailto:[email protected] Marcus Nyeholt}
11
- * This file is part of the PRADO framework from {@link http://www.xisc.com}
12
- *
13
- * @author Marcus Nyeholt		<[email protected]>
14
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
15
- * @package System.Web.Services.SOAP
16
- */
3
+	 * Wsdl file.
4
+	 *
5
+	 * This program is free software; you can redistribute it and/or modify
6
+	 * it under the terms of the BSD License.
7
+	 *
8
+	 * Copyright(c) 2005 by Marcus Nyeholt. All rights reserved.
9
+	 *
10
+	 * To contact the author write to {@link mailto:[email protected] Marcus Nyeholt}
11
+	 * This file is part of the PRADO framework from {@link http://www.xisc.com}
12
+	 *
13
+	 * @author Marcus Nyeholt		<[email protected]>
14
+	 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
15
+	 * @package System.Web.Services.SOAP
16
+	 */
17 17
 
18 18
 /**
19 19
  * Contains the dom object used to build up the wsdl. The
Please login to merge, or discard this patch.
framework/3rdParty/WsdlGen/WsdlMessage.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * WsdlMessage file.
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the BSD License.
7
- *
8
- * Copyright(c) 2005 by Marcus Nyeholt. All rights reserved.
9
- *
10
- * To contact the author write to {@link mailto:[email protected] Marcus Nyeholt}
11
- * This file is part of the PRADO framework from {@link http://www.xisc.com}
12
- *
13
- * @author Marcus Nyeholt		<[email protected]>
14
- * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
15
- * @package System.Web.Services.SOAP
16
- */
3
+	 * WsdlMessage file.
4
+	 *
5
+	 * This program is free software; you can redistribute it and/or modify
6
+	 * it under the terms of the BSD License.
7
+	 *
8
+	 * Copyright(c) 2005 by Marcus Nyeholt. All rights reserved.
9
+	 *
10
+	 * To contact the author write to {@link mailto:[email protected] Marcus Nyeholt}
11
+	 * This file is part of the PRADO framework from {@link http://www.xisc.com}
12
+	 *
13
+	 * @author Marcus Nyeholt		<[email protected]>
14
+	 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
15
+	 * @package System.Web.Services.SOAP
16
+	 */
17 17
 
18 18
 /**
19 19
  * Represents a WSDL message. This is bound to the portTypes
Please login to merge, or discard this patch.
framework/3rdParty/FirePHPCore/fb.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
    * @return void
74 74
    */
75 75
   public static function setEnabled($Enabled) {
76
-    $instance = FirePHP::getInstance(true);
77
-    $instance->setEnabled($Enabled);
76
+	$instance = FirePHP::getInstance(true);
77
+	$instance->setEnabled($Enabled);
78 78
   }
79 79
   
80 80
   /**
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
    * @return boolean TRUE if enabled
85 85
    */
86 86
   public static function getEnabled() {
87
-    $instance = FirePHP::getInstance(true);
88
-    return $instance->getEnabled();
87
+	$instance = FirePHP::getInstance(true);
88
+	return $instance->getEnabled();
89 89
   }  
90 90
   
91 91
   /**
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
    * @return void
100 100
    */
101 101
   public static function setObjectFilter($Class, $Filter) {
102
-    $instance = FirePHP::getInstance(true);
103
-    $instance->setObjectFilter($Class, $Filter);
102
+	$instance = FirePHP::getInstance(true);
103
+	$instance->setObjectFilter($Class, $Filter);
104 104
   }
105 105
   
106 106
   /**
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
    * @return void
112 112
    */
113 113
   public static function setOptions($Options) {
114
-    $instance = FirePHP::getInstance(true);
115
-    $instance->setOptions($Options);
114
+	$instance = FirePHP::getInstance(true);
115
+	$instance->setOptions($Options);
116 116
   }
117 117
 
118 118
   /**
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
    * @return array The options
123 123
    */
124 124
   public static function getOptions() {
125
-    $instance = FirePHP::getInstance(true);
126
-    return $instance->getOptions();
125
+	$instance = FirePHP::getInstance(true);
126
+	return $instance->getOptions();
127 127
   }
128 128
 
129 129
   /**
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
    */
137 137
   public static function send()
138 138
   {
139
-    $instance = FirePHP::getInstance(true);
140
-    $args = func_get_args();
141
-    return call_user_func_array(array($instance,'fb'),$args);
139
+	$instance = FirePHP::getInstance(true);
140
+	$args = func_get_args();
141
+	return call_user_func_array(array($instance,'fb'),$args);
142 142
   }
143 143
 
144 144
   /**
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
    * @return true
154 154
    */
155 155
   public static function group($Name, $Options=null) {
156
-    $instance = FirePHP::getInstance(true);
157
-    return $instance->group($Name, $Options);
156
+	$instance = FirePHP::getInstance(true);
157
+	return $instance->group($Name, $Options);
158 158
   }
159 159
 
160 160
   /**
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
    * @throws Exception
165 165
    */
166 166
   public static function groupEnd() {
167
-    return self::send(null, null, FirePHP::GROUP_END);
167
+	return self::send(null, null, FirePHP::GROUP_END);
168 168
   }
169 169
 
170 170
   /**
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
    * @throws Exception
178 178
    */
179 179
   public static function log($Object, $Label=null) {
180
-    return self::send($Object, $Label, FirePHP::LOG);
180
+	return self::send($Object, $Label, FirePHP::LOG);
181 181
   } 
182 182
 
183 183
   /**
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
    * @throws Exception
191 191
    */
192 192
   public static function info($Object, $Label=null) {
193
-    return self::send($Object, $Label, FirePHP::INFO);
193
+	return self::send($Object, $Label, FirePHP::INFO);
194 194
   } 
195 195
 
196 196
   /**
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
    * @throws Exception
204 204
    */
205 205
   public static function warn($Object, $Label=null) {
206
-    return self::send($Object, $Label, FirePHP::WARN);
206
+	return self::send($Object, $Label, FirePHP::WARN);
207 207
   } 
208 208
 
209 209
   /**
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
    * @throws Exception
217 217
    */
218 218
   public static function error($Object, $Label=null) {
219
-    return self::send($Object, $Label, FirePHP::ERROR);
219
+	return self::send($Object, $Label, FirePHP::ERROR);
220 220
   } 
221 221
 
222 222
   /**
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
    * @throws Exception
230 230
    */
231 231
   public static function dump($Key, $Variable) {
232
-    return self::send($Variable, $Key, FirePHP::DUMP);
232
+	return self::send($Variable, $Key, FirePHP::DUMP);
233 233
   } 
234 234
 
235 235
   /**
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
    * @throws Exception
242 242
    */
243 243
   public static function trace($Label) {
244
-    return self::send($Label, FirePHP::TRACE);
244
+	return self::send($Label, FirePHP::TRACE);
245 245
   } 
246 246
 
247 247
   /**
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
    * @throws Exception
255 255
    */
256 256
   public static function table($Label, $Table) {
257
-    return self::send($Table, $Label, FirePHP::TABLE);
257
+	return self::send($Table, $Label, FirePHP::TABLE);
258 258
   } 
259 259
 
260 260
 }
Please login to merge, or discard this patch.
framework/3rdParty/ReCaptcha/recaptchalib.php 1 patch
Indentation   +72 added lines, -73 removed lines patch added patch discarded remove patch
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
  * @return string - encoded request
46 46
  */
47 47
 function _recaptcha_qsencode ($data) {
48
-        $req = "";
49
-        foreach ( $data as $key => $value )
50
-                $req .= $key . '=' . urlencode( stripslashes($value) ) . '&';
48
+		$req = "";
49
+		foreach ( $data as $key => $value )
50
+				$req .= $key . '=' . urlencode( stripslashes($value) ) . '&';
51 51
 
52
-        // Cut the last '&'
53
-        $req=substr($req,0,strlen($req)-1);
54
-        return $req;
52
+		// Cut the last '&'
53
+		$req=substr($req,0,strlen($req)-1);
54
+		return $req;
55 55
 }
56 56
 
57 57
 
@@ -66,29 +66,29 @@  discard block
 block discarded – undo
66 66
  */
67 67
 function _recaptcha_http_post($host, $path, $data, $port = 80) {
68 68
 
69
-        $req = _recaptcha_qsencode ($data);
69
+		$req = _recaptcha_qsencode ($data);
70 70
 
71
-        $http_request  = "POST $path HTTP/1.0\r\n";
72
-        $http_request .= "Host: $host\r\n";
73
-        $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
74
-        $http_request .= "Content-Length: " . strlen($req) . "\r\n";
75
-        $http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
76
-        $http_request .= "\r\n";
77
-        $http_request .= $req;
71
+		$http_request  = "POST $path HTTP/1.0\r\n";
72
+		$http_request .= "Host: $host\r\n";
73
+		$http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
74
+		$http_request .= "Content-Length: " . strlen($req) . "\r\n";
75
+		$http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
76
+		$http_request .= "\r\n";
77
+		$http_request .= $req;
78 78
 
79
-        $response = '';
80
-        if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
81
-                die ('Could not open socket');
82
-        }
79
+		$response = '';
80
+		if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
81
+				die ('Could not open socket');
82
+		}
83 83
 
84
-        fwrite($fs, $http_request);
84
+		fwrite($fs, $http_request);
85 85
 
86
-        while ( !feof($fs) )
87
-                $response .= fgets($fs, 1160); // One TCP-IP packet
88
-        fclose($fs);
89
-        $response = explode("\r\n\r\n", $response, 2);
86
+		while ( !feof($fs) )
87
+				$response .= fgets($fs, 1160); // One TCP-IP packet
88
+		fclose($fs);
89
+		$response = explode("\r\n\r\n", $response, 2);
90 90
 
91
-        return $response;
91
+		return $response;
92 92
 }
93 93
 
94 94
 
@@ -100,7 +100,6 @@  discard block
 block discarded – undo
100 100
  * @param string $pubkey A public key for reCAPTCHA
101 101
  * @param string $error The error given by reCAPTCHA (optional, default is null)
102 102
  * @param boolean $use_ssl Should the request be made over ssl? (optional, default is false)
103
-
104 103
  * @return string - The HTML to be embedded in the user's form.
105 104
  */
106 105
 function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)
@@ -110,16 +109,16 @@  discard block
 block discarded – undo
110 109
 	}
111 110
 	
112 111
 	if ($use_ssl) {
113
-                $server = RECAPTCHA_API_SECURE_SERVER;
114
-        } else {
115
-                $server = RECAPTCHA_API_SERVER;
116
-        }
112
+				$server = RECAPTCHA_API_SECURE_SERVER;
113
+		} else {
114
+				$server = RECAPTCHA_API_SERVER;
115
+		}
117 116
 
118
-        $errorpart = "";
119
-        if ($error) {
120
-           $errorpart = "&amp;error=" . $error;
121
-        }
122
-        return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script>
117
+		$errorpart = "";
118
+		if ($error) {
119
+		   $errorpart = "&amp;error=" . $error;
120
+		}
121
+		return '<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script>
123 122
 
124 123
 	<noscript>
125 124
   		<iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe><br/>
@@ -135,20 +134,20 @@  discard block
 block discarded – undo
135 134
  * A ReCaptchaResponse is returned from recaptcha_check_answer()
136 135
  */
137 136
 class ReCaptchaResponse {
138
-        var $is_valid;
139
-        var $error;
137
+		var $is_valid;
138
+		var $error;
140 139
 }
141 140
 
142 141
 
143 142
 /**
144
-  * Calls an HTTP POST function to verify if the user's guess was correct
145
-  * @param string $privkey
146
-  * @param string $remoteip
147
-  * @param string $challenge
148
-  * @param string $response
149
-  * @param array $extra_params an array of extra variables to post to the server
150
-  * @return ReCaptchaResponse
151
-  */
143
+ * Calls an HTTP POST function to verify if the user's guess was correct
144
+ * @param string $privkey
145
+ * @param string $remoteip
146
+ * @param string $challenge
147
+ * @param string $response
148
+ * @param array $extra_params an array of extra variables to post to the server
149
+ * @return ReCaptchaResponse
150
+ */
152 151
 function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array())
153 152
 {
154 153
 	if ($privkey == null || $privkey == '') {
@@ -161,34 +160,34 @@  discard block
 block discarded – undo
161 160
 
162 161
 	
163 162
 	
164
-        //discard spam submissions
165
-        if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) {
166
-                $recaptcha_response = new ReCaptchaResponse();
167
-                $recaptcha_response->is_valid = false;
168
-                $recaptcha_response->error = 'incorrect-captcha-sol';
169
-                return $recaptcha_response;
170
-        }
171
-
172
-        $response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify",
173
-                                          array (
174
-                                                 'privatekey' => $privkey,
175
-                                                 'remoteip' => $remoteip,
176
-                                                 'challenge' => $challenge,
177
-                                                 'response' => $response
178
-                                                 ) + $extra_params
179
-                                          );
180
-
181
-        $answers = explode ("\n", $response [1]);
182
-        $recaptcha_response = new ReCaptchaResponse();
183
-
184
-        if (trim ($answers [0]) == 'true') {
185
-                $recaptcha_response->is_valid = true;
186
-        }
187
-        else {
188
-                $recaptcha_response->is_valid = false;
189
-                $recaptcha_response->error = $answers [1];
190
-        }
191
-        return $recaptcha_response;
163
+		//discard spam submissions
164
+		if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) {
165
+				$recaptcha_response = new ReCaptchaResponse();
166
+				$recaptcha_response->is_valid = false;
167
+				$recaptcha_response->error = 'incorrect-captcha-sol';
168
+				return $recaptcha_response;
169
+		}
170
+
171
+		$response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify",
172
+										  array (
173
+												 'privatekey' => $privkey,
174
+												 'remoteip' => $remoteip,
175
+												 'challenge' => $challenge,
176
+												 'response' => $response
177
+												 ) + $extra_params
178
+										  );
179
+
180
+		$answers = explode ("\n", $response [1]);
181
+		$recaptcha_response = new ReCaptchaResponse();
182
+
183
+		if (trim ($answers [0]) == 'true') {
184
+				$recaptcha_response->is_valid = true;
185
+		}
186
+		else {
187
+				$recaptcha_response->is_valid = false;
188
+				$recaptcha_response->error = $answers [1];
189
+		}
190
+		return $recaptcha_response;
192 191
 
193 192
 }
194 193
 
@@ -230,7 +229,7 @@  discard block
 block discarded – undo
230 229
 function recaptcha_mailhide_url($pubkey, $privkey, $email) {
231 230
 	if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) {
232 231
 		die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " .
233
-		     "you can do so at <a href='http://www.google.com/recaptcha/mailhide/apikey'>http://www.google.com/recaptcha/mailhide/apikey</a>");
232
+			 "you can do so at <a href='http://www.google.com/recaptcha/mailhide/apikey'>http://www.google.com/recaptcha/mailhide/apikey</a>");
234 233
 	}
235 234
 	
236 235
 
Please login to merge, or discard this patch.
framework/3rdParty/SafeHtml/HTMLSax3.php 1 patch
Indentation   +604 added lines, -604 removed lines patch added patch discarded remove patch
@@ -39,114 +39,114 @@  discard block
 block discarded – undo
39 39
 * @abstract
40 40
 */
41 41
 class TSax3_StateParser {
42
-    /**
43
-    * Instance of user front end class to be passed to callbacks
44
-    * @var TSax3
45
-    * @access private
46
-    */
47
-    public $htmlsax;
48
-    /**
49
-    * User defined object for handling elements
50
-    * @var object
51
-    * @access private
52
-    */
53
-    public $handler_object_element;
54
-    /**
55
-    * User defined open tag handler method
56
-    * @var string
57
-    * @access private
58
-    */
59
-    public $handler_method_opening;
60
-    /**
61
-    * User defined close tag handler method
62
-    * @var string
63
-    * @access private
64
-    */
65
-    public $handler_method_closing;
66
-    /**
67
-    * User defined object for handling data in elements
68
-    * @var object
69
-    * @access private
70
-    */
71
-    public $handler_object_data;
72
-    /**
73
-    * User defined data handler method
74
-    * @var string
75
-    * @access private
76
-    */
77
-    public $handler_method_data;
78
-    /**
79
-    * User defined object for handling processing instructions
80
-    * @var object
81
-    * @access private
82
-    */
83
-    public $handler_object_pi;
84
-    /**
85
-    * User defined processing instruction handler method
86
-    * @var string
87
-    * @access private
88
-    */
89
-    public $handler_method_pi;
90
-    /**
91
-    * User defined object for handling JSP/ASP tags
92
-    * @var object
93
-    * @access private
94
-    */
95
-    public $handler_object_jasp;
96
-    /**
97
-    * User defined JSP/ASP handler method
98
-    * @var string
99
-    * @access private
100
-    */
101
-    public $handler_method_jasp;
102
-    /**
103
-    * User defined object for handling XML escapes
104
-    * @var object
105
-    * @access private
106
-    */
107
-    public $handler_object_escape;
108
-    /**
109
-    * User defined XML escape handler method
110
-    * @var string
111
-    * @access private
112
-    */
113
-    public $handler_method_escape;
114
-    /**
115
-    * User defined handler object or NullHandler
116
-    * @var object
117
-    * @access private
118
-    */
119
-    public $handler_default;
120
-    /**
121
-    * Parser options determining parsing behavior
122
-    * @var array
123
-    * @access private
124
-    */
125
-    protected $parser_options = array();
126
-    /**
127
-    * XML document being parsed
128
-    * @var string
129
-    * @access private
130
-    */
131
-    protected $rawtext;
132
-    /**
133
-    * Position in XML document relative to start (0)
134
-    * @var int
135
-    * @access private
136
-    */
137
-    protected $position;
138
-    /**
139
-    * Length of the XML document in characters
140
-    * @var int
141
-    * @access private
142
-    */
143
-    protected $length;
144
-    /**
145
-    * Array of state objects
146
-    * @var array
147
-    * @access private
148
-    */
149
-    protected $State = array();
42
+	/**
43
+	 * Instance of user front end class to be passed to callbacks
44
+	 * @var TSax3
45
+	 * @access private
46
+	 */
47
+	public $htmlsax;
48
+	/**
49
+	 * User defined object for handling elements
50
+	 * @var object
51
+	 * @access private
52
+	 */
53
+	public $handler_object_element;
54
+	/**
55
+	 * User defined open tag handler method
56
+	 * @var string
57
+	 * @access private
58
+	 */
59
+	public $handler_method_opening;
60
+	/**
61
+	 * User defined close tag handler method
62
+	 * @var string
63
+	 * @access private
64
+	 */
65
+	public $handler_method_closing;
66
+	/**
67
+	 * User defined object for handling data in elements
68
+	 * @var object
69
+	 * @access private
70
+	 */
71
+	public $handler_object_data;
72
+	/**
73
+	 * User defined data handler method
74
+	 * @var string
75
+	 * @access private
76
+	 */
77
+	public $handler_method_data;
78
+	/**
79
+	 * User defined object for handling processing instructions
80
+	 * @var object
81
+	 * @access private
82
+	 */
83
+	public $handler_object_pi;
84
+	/**
85
+	 * User defined processing instruction handler method
86
+	 * @var string
87
+	 * @access private
88
+	 */
89
+	public $handler_method_pi;
90
+	/**
91
+	 * User defined object for handling JSP/ASP tags
92
+	 * @var object
93
+	 * @access private
94
+	 */
95
+	public $handler_object_jasp;
96
+	/**
97
+	 * User defined JSP/ASP handler method
98
+	 * @var string
99
+	 * @access private
100
+	 */
101
+	public $handler_method_jasp;
102
+	/**
103
+	 * User defined object for handling XML escapes
104
+	 * @var object
105
+	 * @access private
106
+	 */
107
+	public $handler_object_escape;
108
+	/**
109
+	 * User defined XML escape handler method
110
+	 * @var string
111
+	 * @access private
112
+	 */
113
+	public $handler_method_escape;
114
+	/**
115
+	 * User defined handler object or NullHandler
116
+	 * @var object
117
+	 * @access private
118
+	 */
119
+	public $handler_default;
120
+	/**
121
+	 * Parser options determining parsing behavior
122
+	 * @var array
123
+	 * @access private
124
+	 */
125
+	protected $parser_options = array();
126
+	/**
127
+	 * XML document being parsed
128
+	 * @var string
129
+	 * @access private
130
+	 */
131
+	protected $rawtext;
132
+	/**
133
+	 * Position in XML document relative to start (0)
134
+	 * @var int
135
+	 * @access private
136
+	 */
137
+	protected $position;
138
+	/**
139
+	 * Length of the XML document in characters
140
+	 * @var int
141
+	 * @access private
142
+	 */
143
+	protected $length;
144
+	/**
145
+	 * Array of state objects
146
+	 * @var array
147
+	 * @access private
148
+	 */
149
+	protected $State = array();
150 150
 
151 151
 	const TSAX3_STATE_STOP = 0;
152 152
 	const TSAX3_STATE_START = 1;
@@ -157,166 +157,166 @@  discard block
 block discarded – undo
157 157
 	const TSAX3_STATE_JASP = 7;
158 158
 	const TSAX3_STATE_PI = 8;
159 159
 
160
-    /**
161
-    * Constructs TSax3_StateParser setting up states
162
-    * @var TSax3 instance of user front end class
163
-    * @access protected
164
-    */
165
-    protected function __construct($htmlsax) {
166
-        $this->htmlsax = $htmlsax;
167
-        $this->State[self::TSAX3_STATE_START] = new TSax3_StartingState();
168
-
169
-        $this->State[self::TSAX3_STATE_CLOSING_TAG] = new TSax3_ClosingTagState();
170
-        $this->State[self::TSAX3_STATE_TAG] = new TSax3_TagState();
171
-        $this->State[self::TSAX3_STATE_OPENING_TAG] = new TSax3_OpeningTagState();
172
-
173
-        $this->State[self::TSAX3_STATE_PI] = new TSax3_PiState();
174
-        $this->State[self::TSAX3_STATE_JASP] = new TSax3_JaspState();
175
-        $this->State[self::TSAX3_STATE_ESCAPE] = new TSax3_EscapeState();
176
-    }
177
-
178
-    /**
179
-    * Moves the position back one character
180
-    * @access protected
181
-    * @return void
182
-    */
183
-    function unscanCharacter() {
184
-        $this->position -= 1;
185
-    }
186
-
187
-    /**
188
-    * Moves the position forward one character
189
-    * @access protected
190
-    * @return void
191
-    */
192
-    function ignoreCharacter() {
193
-        $this->position += 1;
194
-    }
195
-
196
-    /**
197
-    * Returns the next character from the XML document or void if at end
198
-    * @access protected
199
-    * @return mixed
200
-    */
201
-    function scanCharacter() {
202
-        if ($this->position < $this->length) {
203
-            return $this->rawtext{$this->position++};
204
-        }
205
-    }
206
-
207
-    /**
208
-    * Returns a string from the current position to the next occurance
209
-    * of the supplied string
210
-    * @param string string to search until
211
-    * @access protected
212
-    * @return string
213
-    */
214
-    function scanUntilString($string) {
215
-        $start = $this->position;
216
-        $this->position = strpos($this->rawtext, $string, $start);
217
-        if ($this->position === FALSE) {
218
-            $this->position = $this->length;
219
-        }
220
-        return substr($this->rawtext, $start, $this->position - $start);
221
-    }
222
-
223
-    /**
224
-    * Returns a string from the current position until the first instance of
225
-    * one of the characters in the supplied string argument
226
-    * @param string string to search until
227
-    * @access protected
228
-    * @return string
229
-    * @abstract
230
-    */
231
-    function scanUntilCharacters($string) {}
232
-
233
-    /**
234
-    * Moves the position forward past any whitespace characters
235
-    * @access protected
236
-    * @return void
237
-    * @abstract
238
-    */
239
-    function ignoreWhitespace() {}
240
-
241
-    /**
242
-    * Begins the parsing operation, setting up any decorators, depending on
243
-    * parse options invoking _parse() to execute parsing
244
-    * @param string XML document to parse
245
-    * @access protected
246
-    * @return void
247
-    */
248
-    function parse($data) {
249
-        if ($this->parser_options['XML_OPTION_TRIM_DATA_NODES']==1) {
250
-            $decorator = new TSax3_Trim(
251
-                $this->handler_object_data,
252
-                $this->handler_method_data);
253
-            $this->handler_object_data =& $decorator;
254
-            $this->handler_method_data = 'trimData';
255
-        }
256
-        if ($this->parser_options['XML_OPTION_CASE_FOLDING']==1) {
257
-            $open_decor = new TSax3_CaseFolding(
258
-                $this->handler_object_element,
259
-                $this->handler_method_opening,
260
-                $this->handler_method_closing);
261
-            $this->handler_object_element =& $open_decor;
262
-            $this->handler_method_opening ='foldOpen';
263
-            $this->handler_method_closing ='foldClose';
264
-        }
265
-        if ($this->parser_options['XML_OPTION_LINEFEED_BREAK']==1) {
266
-            $decorator = new TSax3_Linefeed(
267
-                $this->handler_object_data,
268
-                $this->handler_method_data);
269
-            $this->handler_object_data =& $decorator;
270
-            $this->handler_method_data = 'breakData';
271
-        }
272
-        if ($this->parser_options['XML_OPTION_TAB_BREAK']==1) {
273
-            $decorator = new TSax3_Tab(
274
-                $this->handler_object_data,
275
-                $this->handler_method_data);
276
-            $this->handler_object_data =& $decorator;
277
-            $this->handler_method_data = 'breakData';
278
-        }
279
-        if ($this->parser_options['XML_OPTION_ENTITIES_UNPARSED']==1) {
280
-            $decorator = new TSax3_Entities_Unparsed(
281
-                $this->handler_object_data,
282
-                $this->handler_method_data);
283
-            $this->handler_object_data =& $decorator;
284
-            $this->handler_method_data = 'breakData';
285
-        }
286
-        if ($this->parser_options['XML_OPTION_ENTITIES_PARSED']==1) {
287
-            $decorator = new TSax3_Entities_Parsed(
288
-                $this->handler_object_data,
289
-                $this->handler_method_data);
290
-            $this->handler_object_data =& $decorator;
291
-            $this->handler_method_data = 'breakData';
292
-        }
293
-        // Note switched on by default
294
-        if ($this->parser_options['XML_OPTION_STRIP_ESCAPES']==1) {
295
-            $decorator = new TSax3_Escape_Stripper(
296
-                $this->handler_object_escape,
297
-                $this->handler_method_escape);
298
-            $this->handler_object_escape =& $decorator;
299
-            $this->handler_method_escape = 'strip';
300
-        }
301
-        $this->rawtext = $data;
302
-        $this->length = strlen($data);
303
-        $this->position = 0;
304
-        $this->_parse();
305
-    }
306
-
307
-    /**
308
-    * Performs the parsing itself, delegating calls to a specific parser
309
-    * state
310
-    * @param constant state object to parse with
311
-    * @access protected
312
-    * @return void
313
-    */
314
-    function _parse($state = self::TSAX3_STATE_START) {
315
-        do {
316
-            $state = $this->State[$state]->parse($this);
317
-        } while ($state != self::TSAX3_STATE_STOP &&
318
-                    $this->position < $this->length);
319
-    }
160
+	/**
161
+	 * Constructs TSax3_StateParser setting up states
162
+	 * @var TSax3 instance of user front end class
163
+	 * @access protected
164
+	 */
165
+	protected function __construct($htmlsax) {
166
+		$this->htmlsax = $htmlsax;
167
+		$this->State[self::TSAX3_STATE_START] = new TSax3_StartingState();
168
+
169
+		$this->State[self::TSAX3_STATE_CLOSING_TAG] = new TSax3_ClosingTagState();
170
+		$this->State[self::TSAX3_STATE_TAG] = new TSax3_TagState();
171
+		$this->State[self::TSAX3_STATE_OPENING_TAG] = new TSax3_OpeningTagState();
172
+
173
+		$this->State[self::TSAX3_STATE_PI] = new TSax3_PiState();
174
+		$this->State[self::TSAX3_STATE_JASP] = new TSax3_JaspState();
175
+		$this->State[self::TSAX3_STATE_ESCAPE] = new TSax3_EscapeState();
176
+	}
177
+
178
+	/**
179
+	 * Moves the position back one character
180
+	 * @access protected
181
+	 * @return void
182
+	 */
183
+	function unscanCharacter() {
184
+		$this->position -= 1;
185
+	}
186
+
187
+	/**
188
+	 * Moves the position forward one character
189
+	 * @access protected
190
+	 * @return void
191
+	 */
192
+	function ignoreCharacter() {
193
+		$this->position += 1;
194
+	}
195
+
196
+	/**
197
+	 * Returns the next character from the XML document or void if at end
198
+	 * @access protected
199
+	 * @return mixed
200
+	 */
201
+	function scanCharacter() {
202
+		if ($this->position < $this->length) {
203
+			return $this->rawtext{$this->position++};
204
+		}
205
+	}
206
+
207
+	/**
208
+	 * Returns a string from the current position to the next occurance
209
+	 * of the supplied string
210
+	 * @param string string to search until
211
+	 * @access protected
212
+	 * @return string
213
+	 */
214
+	function scanUntilString($string) {
215
+		$start = $this->position;
216
+		$this->position = strpos($this->rawtext, $string, $start);
217
+		if ($this->position === FALSE) {
218
+			$this->position = $this->length;
219
+		}
220
+		return substr($this->rawtext, $start, $this->position - $start);
221
+	}
222
+
223
+	/**
224
+	 * Returns a string from the current position until the first instance of
225
+	 * one of the characters in the supplied string argument
226
+	 * @param string string to search until
227
+	 * @access protected
228
+	 * @return string
229
+	 * @abstract
230
+	 */
231
+	function scanUntilCharacters($string) {}
232
+
233
+	/**
234
+	 * Moves the position forward past any whitespace characters
235
+	 * @access protected
236
+	 * @return void
237
+	 * @abstract
238
+	 */
239
+	function ignoreWhitespace() {}
240
+
241
+	/**
242
+	 * Begins the parsing operation, setting up any decorators, depending on
243
+	 * parse options invoking _parse() to execute parsing
244
+	 * @param string XML document to parse
245
+	 * @access protected
246
+	 * @return void
247
+	 */
248
+	function parse($data) {
249
+		if ($this->parser_options['XML_OPTION_TRIM_DATA_NODES']==1) {
250
+			$decorator = new TSax3_Trim(
251
+				$this->handler_object_data,
252
+				$this->handler_method_data);
253
+			$this->handler_object_data =& $decorator;
254
+			$this->handler_method_data = 'trimData';
255
+		}
256
+		if ($this->parser_options['XML_OPTION_CASE_FOLDING']==1) {
257
+			$open_decor = new TSax3_CaseFolding(
258
+				$this->handler_object_element,
259
+				$this->handler_method_opening,
260
+				$this->handler_method_closing);
261
+			$this->handler_object_element =& $open_decor;
262
+			$this->handler_method_opening ='foldOpen';
263
+			$this->handler_method_closing ='foldClose';
264
+		}
265
+		if ($this->parser_options['XML_OPTION_LINEFEED_BREAK']==1) {
266
+			$decorator = new TSax3_Linefeed(
267
+				$this->handler_object_data,
268
+				$this->handler_method_data);
269
+			$this->handler_object_data =& $decorator;
270
+			$this->handler_method_data = 'breakData';
271
+		}
272
+		if ($this->parser_options['XML_OPTION_TAB_BREAK']==1) {
273
+			$decorator = new TSax3_Tab(
274
+				$this->handler_object_data,
275
+				$this->handler_method_data);
276
+			$this->handler_object_data =& $decorator;
277
+			$this->handler_method_data = 'breakData';
278
+		}
279
+		if ($this->parser_options['XML_OPTION_ENTITIES_UNPARSED']==1) {
280
+			$decorator = new TSax3_Entities_Unparsed(
281
+				$this->handler_object_data,
282
+				$this->handler_method_data);
283
+			$this->handler_object_data =& $decorator;
284
+			$this->handler_method_data = 'breakData';
285
+		}
286
+		if ($this->parser_options['XML_OPTION_ENTITIES_PARSED']==1) {
287
+			$decorator = new TSax3_Entities_Parsed(
288
+				$this->handler_object_data,
289
+				$this->handler_method_data);
290
+			$this->handler_object_data =& $decorator;
291
+			$this->handler_method_data = 'breakData';
292
+		}
293
+		// Note switched on by default
294
+		if ($this->parser_options['XML_OPTION_STRIP_ESCAPES']==1) {
295
+			$decorator = new TSax3_Escape_Stripper(
296
+				$this->handler_object_escape,
297
+				$this->handler_method_escape);
298
+			$this->handler_object_escape =& $decorator;
299
+			$this->handler_method_escape = 'strip';
300
+		}
301
+		$this->rawtext = $data;
302
+		$this->length = strlen($data);
303
+		$this->position = 0;
304
+		$this->_parse();
305
+	}
306
+
307
+	/**
308
+	 * Performs the parsing itself, delegating calls to a specific parser
309
+	 * state
310
+	 * @param constant state object to parse with
311
+	 * @access protected
312
+	 * @return void
313
+	 */
314
+	function _parse($state = self::TSAX3_STATE_START) {
315
+		do {
316
+			$state = $this->State[$state]->parse($this);
317
+		} while ($state != self::TSAX3_STATE_STOP &&
318
+					$this->position < $this->length);
319
+	}
320 320
 }
321 321
 
322 322
 /**
@@ -327,61 +327,61 @@  discard block
 block discarded – undo
327 327
 * @see TSax3_StateParser_Gtet430
328 328
 */
329 329
 class TSax3_StateParser_Lt430 extends TSax3_StateParser {
330
-    /**
331
-    * Constructs TSax3_StateParser_Lt430 defining available
332
-    * parser options
333
-    * @var TSax3 instance of user front end class
334
-    * @access protected
335
-    */
336
-    function __construct(& $htmlsax) {
337
-        parent::__construct($htmlsax);
338
-        $this->parser_options['XML_OPTION_TRIM_DATA_NODES'] = 0;
339
-        $this->parser_options['XML_OPTION_CASE_FOLDING'] = 0;
340
-        $this->parser_options['XML_OPTION_LINEFEED_BREAK'] = 0;
341
-        $this->parser_options['XML_OPTION_TAB_BREAK'] = 0;
342
-        $this->parser_options['XML_OPTION_ENTITIES_PARSED'] = 0;
343
-        $this->parser_options['XML_OPTION_ENTITIES_UNPARSED'] = 0;
344
-        $this->parser_options['XML_OPTION_STRIP_ESCAPES'] = 0;
330
+	/**
331
+	 * Constructs TSax3_StateParser_Lt430 defining available
332
+	 * parser options
333
+	 * @var TSax3 instance of user front end class
334
+	 * @access protected
335
+	 */
336
+	function __construct(& $htmlsax) {
337
+		parent::__construct($htmlsax);
338
+		$this->parser_options['XML_OPTION_TRIM_DATA_NODES'] = 0;
339
+		$this->parser_options['XML_OPTION_CASE_FOLDING'] = 0;
340
+		$this->parser_options['XML_OPTION_LINEFEED_BREAK'] = 0;
341
+		$this->parser_options['XML_OPTION_TAB_BREAK'] = 0;
342
+		$this->parser_options['XML_OPTION_ENTITIES_PARSED'] = 0;
343
+		$this->parser_options['XML_OPTION_ENTITIES_UNPARSED'] = 0;
344
+		$this->parser_options['XML_OPTION_STRIP_ESCAPES'] = 0;
345 345
 		//var_dump($this->parser_options);
346
-    }
347
-
348
-    /**
349
-    * Returns a string from the current position until the first instance of
350
-    * one of the characters in the supplied string argument
351
-    * @param string string to search until
352
-    * @access protected
353
-    * @return string
354
-    */
355
-    function scanUntilCharacters($string) {
356
-        $startpos = $this->position;
357
-        while ($this->position < $this->length && strpos($string, $this->rawtext{$this->position}) === FALSE) {
358
-            $this->position++;
359
-        }
360
-        return substr($this->rawtext, $startpos, $this->position - $startpos);
361
-    }
362
-
363
-    /**
364
-    * Moves the position forward past any whitespace characters
365
-    * @access protected
366
-    * @return void
367
-    */
368
-    function ignoreWhitespace() {
369
-        while ($this->position < $this->length &&
370
-            strpos(" \n\r\t", $this->rawtext{$this->position}) !== FALSE) {
371
-            $this->position++;
372
-        }
373
-    }
374
-
375
-    /**
376
-    * Begins the parsing operation, setting up the unparsed XML entities
377
-    * decorator if necessary then delegating further work to parent
378
-    * @param string XML document to parse
379
-    * @access protected
380
-    * @return void
381
-    */
382
-    function parse($data) {
383
-        parent::parse($data);
384
-    }
346
+	}
347
+
348
+	/**
349
+	 * Returns a string from the current position until the first instance of
350
+	 * one of the characters in the supplied string argument
351
+	 * @param string string to search until
352
+	 * @access protected
353
+	 * @return string
354
+	 */
355
+	function scanUntilCharacters($string) {
356
+		$startpos = $this->position;
357
+		while ($this->position < $this->length && strpos($string, $this->rawtext{$this->position}) === FALSE) {
358
+			$this->position++;
359
+		}
360
+		return substr($this->rawtext, $startpos, $this->position - $startpos);
361
+	}
362
+
363
+	/**
364
+	 * Moves the position forward past any whitespace characters
365
+	 * @access protected
366
+	 * @return void
367
+	 */
368
+	function ignoreWhitespace() {
369
+		while ($this->position < $this->length &&
370
+			strpos(" \n\r\t", $this->rawtext{$this->position}) !== FALSE) {
371
+			$this->position++;
372
+		}
373
+	}
374
+
375
+	/**
376
+	 * Begins the parsing operation, setting up the unparsed XML entities
377
+	 * decorator if necessary then delegating further work to parent
378
+	 * @param string XML document to parse
379
+	 * @access protected
380
+	 * @return void
381
+	 */
382
+	function parse($data) {
383
+		parent::parse($data);
384
+	}
385 385
 }
386 386
 
387 387
 /**
@@ -392,56 +392,56 @@  discard block
 block discarded – undo
392 392
 * @see TSax3_StateParser_Lt430
393 393
 */
394 394
 class TSax3_StateParser_Gtet430 extends TSax3_StateParser {
395
-    /**
396
-    * Constructs TSax3_StateParser_Gtet430 defining available
397
-    * parser options
398
-    * @var TSax3 instance of user front end class
399
-    * @access protected
400
-    */
401
-    function __construct(& $htmlsax) {
402
-        parent::__construct($htmlsax);
403
-        $this->parser_options['XML_OPTION_TRIM_DATA_NODES'] = 0;
404
-        $this->parser_options['XML_OPTION_CASE_FOLDING'] = 0;
405
-        $this->parser_options['XML_OPTION_LINEFEED_BREAK'] = 0;
406
-        $this->parser_options['XML_OPTION_TAB_BREAK'] = 0;
407
-        $this->parser_options['XML_OPTION_ENTITIES_PARSED'] = 0;
408
-        $this->parser_options['XML_OPTION_ENTITIES_UNPARSED'] = 0;
409
-        $this->parser_options['XML_OPTION_STRIP_ESCAPES'] = 0;
410
-    }
411
-    /**
412
-    * Returns a string from the current position until the first instance of
413
-    * one of the characters in the supplied string argument.
414
-    * @param string string to search until
415
-    * @access protected
416
-    * @return string
417
-    */
418
-    function scanUntilCharacters($string) {
419
-        $startpos = $this->position;
420
-        $length = strcspn($this->rawtext, $string, $startpos);
421
-        $this->position += $length;
422
-        return substr($this->rawtext, $startpos, $length);
423
-    }
424
-
425
-    /**
426
-    * Moves the position forward past any whitespace characters
427
-    * @access protected
428
-    * @return void
429
-    */
430
-    function ignoreWhitespace() {
431
-        $this->position += strspn($this->rawtext, " \n\r\t", $this->position);
432
-    }
433
-
434
-    /**
435
-    * Begins the parsing operation, setting up the parsed and unparsed
436
-    * XML entity decorators if necessary then delegating further work
437
-    * to parent
438
-    * @param string XML document to parse
439
-    * @access protected
440
-    * @return void
441
-    */
442
-    function parse($data) {
443
-        parent::parse($data);
444
-    }
395
+	/**
396
+	 * Constructs TSax3_StateParser_Gtet430 defining available
397
+	 * parser options
398
+	 * @var TSax3 instance of user front end class
399
+	 * @access protected
400
+	 */
401
+	function __construct(& $htmlsax) {
402
+		parent::__construct($htmlsax);
403
+		$this->parser_options['XML_OPTION_TRIM_DATA_NODES'] = 0;
404
+		$this->parser_options['XML_OPTION_CASE_FOLDING'] = 0;
405
+		$this->parser_options['XML_OPTION_LINEFEED_BREAK'] = 0;
406
+		$this->parser_options['XML_OPTION_TAB_BREAK'] = 0;
407
+		$this->parser_options['XML_OPTION_ENTITIES_PARSED'] = 0;
408
+		$this->parser_options['XML_OPTION_ENTITIES_UNPARSED'] = 0;
409
+		$this->parser_options['XML_OPTION_STRIP_ESCAPES'] = 0;
410
+	}
411
+	/**
412
+	 * Returns a string from the current position until the first instance of
413
+	 * one of the characters in the supplied string argument.
414
+	 * @param string string to search until
415
+	 * @access protected
416
+	 * @return string
417
+	 */
418
+	function scanUntilCharacters($string) {
419
+		$startpos = $this->position;
420
+		$length = strcspn($this->rawtext, $string, $startpos);
421
+		$this->position += $length;
422
+		return substr($this->rawtext, $startpos, $length);
423
+	}
424
+
425
+	/**
426
+	 * Moves the position forward past any whitespace characters
427
+	 * @access protected
428
+	 * @return void
429
+	 */
430
+	function ignoreWhitespace() {
431
+		$this->position += strspn($this->rawtext, " \n\r\t", $this->position);
432
+	}
433
+
434
+	/**
435
+	 * Begins the parsing operation, setting up the parsed and unparsed
436
+	 * XML entity decorators if necessary then delegating further work
437
+	 * to parent
438
+	 * @param string XML document to parse
439
+	 * @access protected
440
+	 * @return void
441
+	 */
442
+	function parse($data) {
443
+		parent::parse($data);
444
+	}
445 445
 }
446 446
 
447 447
 /**
@@ -450,13 +450,13 @@  discard block
 block discarded – undo
450 450
 * @access protected
451 451
 */
452 452
 class TSax3_NullHandler {
453
-    /**
454
-    * Generic handler method which does nothing
455
-    * @access protected
456
-    * @return void
457
-    */
458
-    function DoNothing() {
459
-    }
453
+	/**
454
+	 * Generic handler method which does nothing
455
+	 * @access protected
456
+	 * @return void
457
+	 */
458
+	function DoNothing() {
459
+	}
460 460
 }
461 461
 
462 462
 /**
@@ -465,229 +465,229 @@  discard block
 block discarded – undo
465 465
 * @access public
466 466
 */
467 467
 class TSax3 {
468
-    /**
469
-    * Instance of concrete subclass of TSax3_StateParser
470
-    * @var TSax3_StateParser
471
-    * @access private
472
-    */
473
-    private $state_parser;
474
-
475
-    /**
476
-    * Constructs TSax3 selecting concrete StateParser subclass
477
-    * depending on PHP version being used as well as setting the default
478
-    * NullHandler for all callbacks<br />
479
-    * <b>Example:</b>
480
-    * <pre>
481
-    * $myHandler = & new MyHandler();
482
-    * $parser = new TSax3();
483
-    * $parser->set_object($myHandler);
484
-    * $parser->set_option('XML_OPTION_CASE_FOLDING');
485
-    * $parser->set_element_handler('myOpenHandler','myCloseHandler');
486
-    * $parser->set_data_handler('myDataHandler');
487
-    * $parser->parser($xml);
488
-    * </pre>
489
-    * @access public
490
-    */
491
-    function __construct() {
492
-        if (version_compare(phpversion(), '4.3', 'ge')) {
493
-            $this->state_parser = new TSax3_StateParser_Gtet430($this);
494
-        } else {
495
-            $this->state_parser = new TSax3_StateParser_Lt430($this);
496
-        }
497
-        $nullhandler = new TSax3_NullHandler();
498
-        $this->set_object($nullhandler);
499
-        $this->set_element_handler('DoNothing', 'DoNothing');
500
-        $this->set_data_handler('DoNothing');
501
-        $this->set_pi_handler('DoNothing');
502
-        $this->set_jasp_handler('DoNothing');
503
-        $this->set_escape_handler('DoNothing');
504
-    }
505
-
506
-    /**
507
-    * Sets the user defined handler object. Returns a PEAR Error
508
-    * if supplied argument is not an object.
509
-    * @param object handler object containing SAX callback methods
510
-    * @access public
511
-    * @return mixed
512
-    */
513
-    function set_object(&$object) {
514
-        if ( is_object($object) ) {
515
-            $this->state_parser->handler_default =& $object;
516
-            return true;
517
-        } else {
518
-            require_once('PEAR.php');
519
-            PEAR::raiseError('TSax3::set_object requires '.
520
-                'an object instance');
521
-        }
522
-    }
523
-
524
-    /**
525
-    * Sets a parser option. By default all options are switched off.
526
-    * Returns a PEAR Error if option is invalid<br />
527
-    * <b>Available options:</b>
528
-    * <ul>
529
-    * <li>XML_OPTION_TRIM_DATA_NODES: trim whitespace off the beginning
530
-    * and end of data passed to the data handler</li>
531
-    * <li>XML_OPTION_LINEFEED_BREAK: linefeeds result in additional data
532
-    * handler calls</li>
533
-    * <li>XML_OPTION_TAB_BREAK: tabs result in additional data handler
534
-    * calls</li>
535
-    * <li>XML_OPTION_ENTITIES_UNPARSED: XML entities are returned as
536
-    * seperate data handler calls in unparsed form</li>
537
-    * <li>XML_OPTION_ENTITIES_PARSED: (PHP 4.3.0+ only) XML entities are
538
-    * returned as seperate data handler calls and are parsed with
539
-    * PHP's html_entity_decode() function</li>
540
-    * <li>XML_OPTION_STRIP_ESCAPES: strips out the -- -- comment markers
541
-    * or CDATA markup inside an XML escape, if found.</li>
542
-    * </ul>
543
-    * To get HTMLSax to behave in the same way as the native PHP SAX parser,
544
-    * using it's default state, you need to switch on XML_OPTION_LINEFEED_BREAK,
545
-    * XML_OPTION_ENTITIES_PARSED and XML_OPTION_CASE_FOLDING
546
-    * @param string name of parser option
547
-    * @param int (optional) 1 to switch on, 0 for off
548
-    * @access public
549
-    * @return boolean
550
-    */
551
-    function set_option($name, $value=1) {
552
-        if ( array_key_exists($name,$this->state_parser->parser_options) ) {
553
-            $this->state_parser->parser_options[$name] = $value;
554
-            return true;
555
-        } else {
556
-            require_once('PEAR.php');
557
-            PEAR::raiseError('TSax3::set_option('.$name.') illegal');
558
-        }
559
-    }
560
-
561
-    /**
562
-    * Sets the data handler method which deals with the contents of XML
563
-    * elements.<br />
564
-    * The handler method must accept two arguments, the first being an
565
-    * instance of TSax3 and the second being the contents of an
566
-    * XML element e.g.
567
-    * <pre>
568
-    * function myDataHander(& $parser,$data){}
569
-    * </pre>
570
-    * @param string name of method
571
-    * @access public
572
-    * @return void
573
-    * @see set_object
574
-    */
575
-    function set_data_handler($data_method) {
576
-        $this->state_parser->handler_object_data =& $this->state_parser->handler_default;
577
-        $this->state_parser->handler_method_data = $data_method;
578
-    }
579
-
580
-    /**
581
-    * Sets the open and close tag handlers
582
-    * <br />The open handler method must accept three arguments; the parser,
583
-    * the tag name and an array of attributes e.g.
584
-    * <pre>
585
-    * function myOpenHander(& $parser,$tagname,$attrs=array()){}
586
-    * </pre>
587
-    * The close handler method must accept two arguments; the parser and
588
-    * the tag name e.g.
589
-    * <pre>
590
-    * function myCloseHander(& $parser,$tagname){}
591
-    * </pre>
592
-    * @param string name of open method
593
-    * @param string name of close method
594
-    * @access public
595
-    * @return void
596
-    * @see set_object
597
-    */
598
-    function set_element_handler($opening_method, $closing_method) {
599
-        $this->state_parser->handler_object_element =& $this->state_parser->handler_default;
600
-        $this->state_parser->handler_method_opening = $opening_method;
601
-        $this->state_parser->handler_method_closing = $closing_method;
602
-    }
603
-
604
-    /**
605
-    * Sets the processing instruction handler method e.g. for PHP open
606
-    * and close tags<br />
607
-    * The handler method must accept three arguments; the parser, the
608
-    * PI target and data inside the PI
609
-    * <pre>
610
-    * function myPIHander(& $parser,$target, $data){}
611
-    * </pre>
612
-    * @param string name of method
613
-    * @access public
614
-    * @return void
615
-    * @see set_object
616
-    */
617
-    function set_pi_handler($pi_method) {
618
-        $this->state_parser->handler_object_pi =& $this->state_parser->handler_default;
619
-        $this->state_parser->handler_method_pi = $pi_method;
620
-    }
621
-
622
-    /**
623
-    * Sets the XML escape handler method e.g. for comments and doctype
624
-    * declarations<br />
625
-    * The handler method must accept two arguments; the parser and the
626
-    * contents of the escaped section
627
-    * <pre>
628
-    * function myEscapeHander(& $parser, $data){}
629
-    * </pre>
630
-    * @param string name of method
631
-    * @access public
632
-    * @return void
633
-    * @see set_object
634
-    */
635
-    function set_escape_handler($escape_method) {
636
-        $this->state_parser->handler_object_escape =& $this->state_parser->handler_default;
637
-        $this->state_parser->handler_method_escape = $escape_method;
638
-    }
639
-
640
-    /**
641
-    * Sets the JSP/ASP markup handler<br />
642
-    * The handler method must accept two arguments; the parser and
643
-    * body of the JASP tag
644
-    * <pre>
645
-    * function myJaspHander(& $parser, $data){}
646
-    * </pre>
647
-    * @param string name of method
648
-    * @access public
649
-    * @return void
650
-    * @see set_object
651
-    */
652
-    function set_jasp_handler ($jasp_method) {
653
-        $this->state_parser->handler_object_jasp =& $this->state_parser->handler_default;
654
-        $this->state_parser->handler_method_jasp = $jasp_method;
655
-    }
656
-
657
-    /**
658
-    * Returns the current string position of the "cursor" inside the XML
659
-    * document
660
-    * <br />Intended for use from within a user defined handler called
661
-    * via the $parser reference e.g.
662
-    * <pre>
663
-    * function myDataHandler(& $parser,$data) {
664
-    *     echo( 'Current position: '.$parser->get_current_position() );
665
-    * }
666
-    * </pre>
667
-    * @access public
668
-    * @return int
669
-    * @see get_length
670
-    */
671
-    function get_current_position() {
672
-        return $this->state_parser->position;
673
-    }
674
-
675
-    /**
676
-    * Returns the string length of the XML document being parsed
677
-    * @access public
678
-    * @return int
679
-    */
680
-    function get_length() {
681
-        return $this->state_parser->length;
682
-    }
683
-
684
-    /**
685
-    * Start parsing some XML
686
-    * @param string XML document
687
-    * @access public
688
-    * @return void
689
-    */
690
-    function parse($data) {
691
-        $this->state_parser->parse($data);
692
-    }
468
+	/**
469
+	 * Instance of concrete subclass of TSax3_StateParser
470
+	 * @var TSax3_StateParser
471
+	 * @access private
472
+	 */
473
+	private $state_parser;
474
+
475
+	/**
476
+	 * Constructs TSax3 selecting concrete StateParser subclass
477
+	 * depending on PHP version being used as well as setting the default
478
+	 * NullHandler for all callbacks<br />
479
+	 * <b>Example:</b>
480
+	 * <pre>
481
+	 * $myHandler = & new MyHandler();
482
+	 * $parser = new TSax3();
483
+	 * $parser->set_object($myHandler);
484
+	 * $parser->set_option('XML_OPTION_CASE_FOLDING');
485
+	 * $parser->set_element_handler('myOpenHandler','myCloseHandler');
486
+	 * $parser->set_data_handler('myDataHandler');
487
+	 * $parser->parser($xml);
488
+	 * </pre>
489
+	 * @access public
490
+	 */
491
+	function __construct() {
492
+		if (version_compare(phpversion(), '4.3', 'ge')) {
493
+			$this->state_parser = new TSax3_StateParser_Gtet430($this);
494
+		} else {
495
+			$this->state_parser = new TSax3_StateParser_Lt430($this);
496
+		}
497
+		$nullhandler = new TSax3_NullHandler();
498
+		$this->set_object($nullhandler);
499
+		$this->set_element_handler('DoNothing', 'DoNothing');
500
+		$this->set_data_handler('DoNothing');
501
+		$this->set_pi_handler('DoNothing');
502
+		$this->set_jasp_handler('DoNothing');
503
+		$this->set_escape_handler('DoNothing');
504
+	}
505
+
506
+	/**
507
+	 * Sets the user defined handler object. Returns a PEAR Error
508
+	 * if supplied argument is not an object.
509
+	 * @param object handler object containing SAX callback methods
510
+	 * @access public
511
+	 * @return mixed
512
+	 */
513
+	function set_object(&$object) {
514
+		if ( is_object($object) ) {
515
+			$this->state_parser->handler_default =& $object;
516
+			return true;
517
+		} else {
518
+			require_once('PEAR.php');
519
+			PEAR::raiseError('TSax3::set_object requires '.
520
+				'an object instance');
521
+		}
522
+	}
523
+
524
+	/**
525
+	 * Sets a parser option. By default all options are switched off.
526
+	 * Returns a PEAR Error if option is invalid<br />
527
+	 * <b>Available options:</b>
528
+	 * <ul>
529
+	 * <li>XML_OPTION_TRIM_DATA_NODES: trim whitespace off the beginning
530
+	 * and end of data passed to the data handler</li>
531
+	 * <li>XML_OPTION_LINEFEED_BREAK: linefeeds result in additional data
532
+	 * handler calls</li>
533
+	 * <li>XML_OPTION_TAB_BREAK: tabs result in additional data handler
534
+	 * calls</li>
535
+	 * <li>XML_OPTION_ENTITIES_UNPARSED: XML entities are returned as
536
+	 * seperate data handler calls in unparsed form</li>
537
+	 * <li>XML_OPTION_ENTITIES_PARSED: (PHP 4.3.0+ only) XML entities are
538
+	 * returned as seperate data handler calls and are parsed with
539
+	 * PHP's html_entity_decode() function</li>
540
+	 * <li>XML_OPTION_STRIP_ESCAPES: strips out the -- -- comment markers
541
+	 * or CDATA markup inside an XML escape, if found.</li>
542
+	 * </ul>
543
+	 * To get HTMLSax to behave in the same way as the native PHP SAX parser,
544
+	 * using it's default state, you need to switch on XML_OPTION_LINEFEED_BREAK,
545
+	 * XML_OPTION_ENTITIES_PARSED and XML_OPTION_CASE_FOLDING
546
+	 * @param string name of parser option
547
+	 * @param int (optional) 1 to switch on, 0 for off
548
+	 * @access public
549
+	 * @return boolean
550
+	 */
551
+	function set_option($name, $value=1) {
552
+		if ( array_key_exists($name,$this->state_parser->parser_options) ) {
553
+			$this->state_parser->parser_options[$name] = $value;
554
+			return true;
555
+		} else {
556
+			require_once('PEAR.php');
557
+			PEAR::raiseError('TSax3::set_option('.$name.') illegal');
558
+		}
559
+	}
560
+
561
+	/**
562
+	 * Sets the data handler method which deals with the contents of XML
563
+	 * elements.<br />
564
+	 * The handler method must accept two arguments, the first being an
565
+	 * instance of TSax3 and the second being the contents of an
566
+	 * XML element e.g.
567
+	 * <pre>
568
+	 * function myDataHander(& $parser,$data){}
569
+	 * </pre>
570
+	 * @param string name of method
571
+	 * @access public
572
+	 * @return void
573
+	 * @see set_object
574
+	 */
575
+	function set_data_handler($data_method) {
576
+		$this->state_parser->handler_object_data =& $this->state_parser->handler_default;
577
+		$this->state_parser->handler_method_data = $data_method;
578
+	}
579
+
580
+	/**
581
+	 * Sets the open and close tag handlers
582
+	 * <br />The open handler method must accept three arguments; the parser,
583
+	 * the tag name and an array of attributes e.g.
584
+	 * <pre>
585
+	 * function myOpenHander(& $parser,$tagname,$attrs=array()){}
586
+	 * </pre>
587
+	 * The close handler method must accept two arguments; the parser and
588
+	 * the tag name e.g.
589
+	 * <pre>
590
+	 * function myCloseHander(& $parser,$tagname){}
591
+	 * </pre>
592
+	 * @param string name of open method
593
+	 * @param string name of close method
594
+	 * @access public
595
+	 * @return void
596
+	 * @see set_object
597
+	 */
598
+	function set_element_handler($opening_method, $closing_method) {
599
+		$this->state_parser->handler_object_element =& $this->state_parser->handler_default;
600
+		$this->state_parser->handler_method_opening = $opening_method;
601
+		$this->state_parser->handler_method_closing = $closing_method;
602
+	}
603
+
604
+	/**
605
+	 * Sets the processing instruction handler method e.g. for PHP open
606
+	 * and close tags<br />
607
+	 * The handler method must accept three arguments; the parser, the
608
+	 * PI target and data inside the PI
609
+	 * <pre>
610
+	 * function myPIHander(& $parser,$target, $data){}
611
+	 * </pre>
612
+	 * @param string name of method
613
+	 * @access public
614
+	 * @return void
615
+	 * @see set_object
616
+	 */
617
+	function set_pi_handler($pi_method) {
618
+		$this->state_parser->handler_object_pi =& $this->state_parser->handler_default;
619
+		$this->state_parser->handler_method_pi = $pi_method;
620
+	}
621
+
622
+	/**
623
+	 * Sets the XML escape handler method e.g. for comments and doctype
624
+	 * declarations<br />
625
+	 * The handler method must accept two arguments; the parser and the
626
+	 * contents of the escaped section
627
+	 * <pre>
628
+	 * function myEscapeHander(& $parser, $data){}
629
+	 * </pre>
630
+	 * @param string name of method
631
+	 * @access public
632
+	 * @return void
633
+	 * @see set_object
634
+	 */
635
+	function set_escape_handler($escape_method) {
636
+		$this->state_parser->handler_object_escape =& $this->state_parser->handler_default;
637
+		$this->state_parser->handler_method_escape = $escape_method;
638
+	}
639
+
640
+	/**
641
+	 * Sets the JSP/ASP markup handler<br />
642
+	 * The handler method must accept two arguments; the parser and
643
+	 * body of the JASP tag
644
+	 * <pre>
645
+	 * function myJaspHander(& $parser, $data){}
646
+	 * </pre>
647
+	 * @param string name of method
648
+	 * @access public
649
+	 * @return void
650
+	 * @see set_object
651
+	 */
652
+	function set_jasp_handler ($jasp_method) {
653
+		$this->state_parser->handler_object_jasp =& $this->state_parser->handler_default;
654
+		$this->state_parser->handler_method_jasp = $jasp_method;
655
+	}
656
+
657
+	/**
658
+	 * Returns the current string position of the "cursor" inside the XML
659
+	 * document
660
+	 * <br />Intended for use from within a user defined handler called
661
+	 * via the $parser reference e.g.
662
+	 * <pre>
663
+	 * function myDataHandler(& $parser,$data) {
664
+	 *     echo( 'Current position: '.$parser->get_current_position() );
665
+	 * }
666
+	 * </pre>
667
+	 * @access public
668
+	 * @return int
669
+	 * @see get_length
670
+	 */
671
+	function get_current_position() {
672
+		return $this->state_parser->position;
673
+	}
674
+
675
+	/**
676
+	 * Returns the string length of the XML document being parsed
677
+	 * @access public
678
+	 * @return int
679
+	 */
680
+	function get_length() {
681
+		return $this->state_parser->length;
682
+	}
683
+
684
+	/**
685
+	 * Start parsing some XML
686
+	 * @param string XML document
687
+	 * @access public
688
+	 * @return void
689
+	 */
690
+	function parse($data) {
691
+		$this->state_parser->parse($data);
692
+	}
693 693
 }
Please login to merge, or discard this patch.
framework/3rdParty/SafeHtml/TSafeHtmlParser.php 1 patch
Indentation   +614 added lines, -614 removed lines patch added patch discarded remove patch
@@ -57,622 +57,622 @@
 block discarded – undo
57 57
  */
58 58
 class TSafeHtmlParser
59 59
 {
60
-    /**
61
-     * Storage for resulting HTML output
62
-     *
63
-     * @var string
64
-     * @access private
65
-     */
66
-    private $_xhtml = '';
67
-
68
-    /**
69
-     * Array of counters for each tag
70
-     *
71
-     * @var array
72
-     * @access private
73
-     */
74
-    private $_counter = array();
75
-
76
-    /**
77
-     * Stack of unclosed tags
78
-     *
79
-     * @var array
80
-     * @access private
81
-     */
82
-    private $_stack = array();
83
-
84
-    /**
85
-     * Array of counters for tags that must be deleted with all content
86
-     *
87
-     * @var array
88
-     * @access private
89
-     */
90
-    private $_dcCounter = array();
91
-
92
-    /**
93
-     * Stack of unclosed tags that must be deleted with all content
94
-     *
95
-     * @var array
96
-     * @access private
97
-     */
98
-    private $_dcStack = array();
99
-
100
-    /**
101
-     * Stores level of list (ol/ul) nesting
102
-     *
103
-     * @var int
104
-     * @access private
105
-     */
106
-    private $_listScope = 0;
107
-
108
-    /**
109
-     * Stack of unclosed list tags
110
-     *
111
-     * @var array
112
-     * @access private
113
-     */
114
-    private $_liStack = array();
115
-
116
-    /**
117
-     * Array of prepared regular expressions for protocols (schemas) matching
118
-     *
119
-     * @var array
120
-     * @access private
121
-     */
122
-    private $_protoRegexps = array();
123
-
124
-    /**
125
-     * Array of prepared regular expressions for CSS matching
126
-     *
127
-     * @var array
128
-     * @access private
129
-     */
130
-    private $_cssRegexps = array();
131
-
132
-    /**
133
-     * List of single tags ("<tag />")
134
-     *
135
-     * @var array
136
-     * @access public
137
-     */
138
-    public $singleTags = array('area', 'br', 'img', 'input', 'hr', 'wbr', );
139
-
140
-    /**
141
-     * List of dangerous tags (such tags will be deleted)
142
-     *
143
-     * @var array
144
-     * @access public
145
-     */
146
-    public $deleteTags = array(
147
-        'applet', 'base',   'basefont', 'bgsound', 'blink',  'body',
148
-        'embed',  'frame',  'frameset', 'head',    'html',   'ilayer',
149
-        'iframe', 'layer',  'link',     'meta',    'object', 'style',
150
-        'title',  'script',
151
-        );
152
-
153
-    /**
154
-     * List of dangerous tags (such tags will be deleted, and all content
155
-     * inside this tags will be also removed)
156
-     *
157
-     * @var array
158
-     * @access public
159
-     */
160
-    public $deleteTagsContent = array('script', 'style', 'title', 'xml', );
161
-
162
-    /**
163
-     * Type of protocols filtering ('white' or 'black')
164
-     *
165
-     * @var string
166
-     * @access public
167
-     */
168
-    public $protocolFiltering = 'white';
169
-
170
-    /**
171
-     * List of "dangerous" protocols (used for blacklist-filtering)
172
-     *
173
-     * @var array
174
-     * @access public
175
-     */
176
-    public $blackProtocols = array(
177
-        'about',   'chrome',     'data',       'disk',     'hcp',
178
-        'help',    'javascript', 'livescript', 'lynxcgi',  'lynxexec',
179
-        'ms-help', 'ms-its',     'mhtml',      'mocha',    'opera',
180
-        'res',     'resource',   'shell',      'vbscript', 'view-source',
181
-        'vnd.ms.radio',          'wysiwyg',
182
-        );
183
-
184
-    /**
185
-     * List of "safe" protocols (used for whitelist-filtering)
186
-     *
187
-     * @var array
188
-     * @access public
189
-     */
190
-    public $whiteProtocols = array(
191
-        'ed2k',   'file', 'ftp',  'gopher', 'http',  'https',
192
-        'irc',    'mailto', 'news', 'nntp', 'telnet', 'webcal',
193
-        'xmpp',   'callto',
194
-        );
195
-
196
-    /**
197
-     * List of attributes that can contain protocols
198
-     *
199
-     * @var array
200
-     * @access public
201
-     */
202
-    public $protocolAttributes = array(
203
-        'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc', 'src',
204
-        );
205
-
206
-    /**
207
-     * List of dangerous CSS keywords
208
-     *
209
-     * Whole style="" attribute will be removed, if parser will find one of
210
-     * these keywords
211
-     *
212
-     * @var array
213
-     * @access public
214
-     */
215
-    public $cssKeywords = array(
216
-        'absolute', 'behavior',       'behaviour',   'content', 'expression',
217
-        'fixed',    'include-source', 'moz-binding',
218
-        );
219
-
220
-    /**
221
-     * List of tags that can have no "closing tag"
222
-     *
223
-     * @var array
224
-     * @access public
225
-     * @deprecated XHTML does not allow such tags
226
-     */
227
-    public $noClose = array();
228
-
229
-    /**
230
-     * List of block-level tags that terminates paragraph
231
-     *
232
-     * Paragraph will be closed when this tags opened
233
-     *
234
-     * @var array
235
-     * @access public
236
-     */
237
-    public $closeParagraph = array(
238
-        'address', 'blockquote', 'center', 'dd',      'dir',       'div',
239
-        'dl',      'dt',         'h1',     'h2',      'h3',        'h4',
240
-        'h5',      'h6',         'hr',     'isindex', 'listing',   'marquee',
241
-        'menu',    'multicol',   'ol',     'p',       'plaintext', 'pre',
242
-        'table',   'ul',         'xmp',
243
-        );
244
-
245
-    /**
246
-     * List of table tags, all table tags outside a table will be removed
247
-     *
248
-     * @var array
249
-     * @access public
250
-     */
251
-    public $tableTags = array(
252
-        'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
253
-        'thead',   'tr',
254
-        );
255
-
256
-    /**
257
-     * List of list tags
258
-     *
259
-     * @var array
260
-     * @access public
261
-     */
262
-    public $listTags = array('dir', 'menu', 'ol', 'ul', 'dl', );
263
-
264
-    /**
265
-     * List of dangerous attributes
266
-     *
267
-     * @var array
268
-     * @access public
269
-     */
270
-    public $attributes = array('dynsrc');
271
-    //public $attributes = array('dynsrc', 'id', 'name', ); //id and name are dangerous?
272
-
273
-    /**
274
-     * List of allowed "namespaced" attributes
275
-     *
276
-     * @var array
277
-     * @access public
278
-     */
279
-    public $attributesNS = array('xml:lang', );
280
-
281
-    /**
282
-     * Constructs class
283
-     *
284
-     * @access public
285
-     */
286
-    public function __construct()
287
-    {
288
-        //making regular expressions based on Proto & CSS arrays
289
-        foreach ($this->blackProtocols as $proto) {
290
-            $preg = "/[\s\x01-\x1F]*";
291
-            for ($i=0; $i<strlen($proto); $i++) {
292
-                $preg .= $proto{$i} . "[\s\x01-\x1F]*";
293
-            }
294
-            $preg .= ":/i";
295
-            $this->_protoRegexps[] = $preg;
296
-        }
297
-
298
-        foreach ($this->cssKeywords as $css) {
299
-            $this->_cssRegexps[] = '/' . $css . '/i';
300
-        }
301
-        return true;
302
-    }
303
-
304
-    /**
305
-     * Handles the writing of attributes - called from $this->_openHandler()
306
-     *
307
-     * @param array $attrs array of attributes $name => $value
308
-     * @return boolean
309
-     * @access private
310
-     */
311
-    private function _writeAttrs ($attrs)
312
-    {
313
-        if (is_array($attrs)) {
314
-            foreach ($attrs as $name => $value) {
315
-
316
-                $name = strtolower($name);
317
-
318
-                if (strpos($name, 'on') === 0) {
319
-                    continue;
320
-                }
321
-                if (strpos($name, 'data') === 0) {
322
-                    continue;
323
-                }
324
-                if (in_array($name, $this->attributes)) {
325
-                    continue;
326
-                }
327
-                if (!preg_match("/^[a-z0-9]+$/i", $name)) {
328
-                    if (!in_array($name, $this->attributesNS))
329
-                    {
330
-                        continue;
331
-                    }
332
-                }
333
-
334
-                if (($value === TRUE) || (is_null($value))) {
335
-                    $value = $name;
336
-                }
337
-
338
-                if ($name == 'style') {
339
-
340
-                   // removes insignificant backslahes
341
-                   $value = str_replace("\\", '', $value);
342
-
343
-                   // removes CSS comments
344
-                   while (1)
345
-                   {
346
-                     $_value = preg_replace("!/\*.*?\*/!s", '', $value);
347
-                     if ($_value == $value) break;
348
-                     $value = $_value;
349
-                   }
350
-
351
-                   // replace all & to &amp;
352
-                   $value = str_replace('&amp;', '&', $value);
353
-                   $value = str_replace('&', '&amp;', $value);
354
-
355
-                   foreach ($this->_cssRegexps as $css) {
356
-                       if (preg_match($css, $value)) {
357
-                           continue 2;
358
-                       }
359
-                   }
360
-                   foreach ($this->_protoRegexps as $proto) {
361
-                       if (preg_match($proto, $value)) {
362
-                           continue 2;
363
-                       }
364
-                   }
365
-                }
366
-
367
-                $tempval = preg_replace_callback(
368
-                        '/&#(\d+);?/m',
369
-                        function ($matches) {
370
-                            return chr($matches[0]);
371
-                        },
372
-                        $value
373
-                    ); //"'
374
-
375
-                $tempval = preg_replace_callback(
376
-                        '/&#x([0-9a-f]+);?/mi',
377
-                        function ($matches) {
378
-                            return chr(hexdec($matches[0]));
379
-                        },
380
-                        $tempval
381
-                    );
382
-
383
-                if ((in_array($name, $this->protocolAttributes)) &&
384
-                    (strpos($tempval, ':') !== false))
385
-                {
386
-                    if ($this->protocolFiltering == 'black') {
387
-                        foreach ($this->_protoRegexps as $proto) {
388
-                            if (preg_match($proto, $tempval)) continue 2;
389
-                        }
390
-                    } else {
391
-                        $_tempval = explode(':', $tempval);
392
-                        $proto = $_tempval[0];
393
-                        if (!in_array($proto, $this->whiteProtocols)) {
394
-                            continue;
395
-                        }
396
-                    }
397
-                }
398
-
399
-                $value = str_replace("\"", "&quot;", $value);
400
-                $this->_xhtml .= ' ' . $name . '="' . $value . '"';
401
-            }
402
-        }
403
-        return true;
404
-    }
405
-
406
-    /**
407
-     * Opening tag handler - called from HTMLSax
408
-     *
409
-     * @param object $parser HTML Parser
410
-     * @param string $name   tag name
411
-     * @param array  $attrs  tag attributes
412
-     * @return boolean
413
-     * @access private
414
-     */
415
-    public function _openHandler(&$parser, $name, $attrs)
416
-    {
417
-        $name = strtolower($name);
418
-
419
-        if (in_array($name, $this->deleteTagsContent)) {
420
-            array_push($this->_dcStack, $name);
421
-            $this->_dcCounter[$name] = isset($this->_dcCounter[$name]) ? $this->_dcCounter[$name]+1 : 1;
422
-        }
423
-        if (count($this->_dcStack) != 0) {
424
-            return true;
425
-        }
426
-
427
-        if (in_array($name, $this->deleteTags)) {
428
-            return true;
429
-        }
430
-
431
-        if (!preg_match("/^[a-z0-9]+$/i", $name)) {
432
-            if (preg_match("!(?:\@|://)!i", $name)) {
433
-                $this->_xhtml .= '&lt;' . $name . '&gt;';
434
-            }
435
-            return true;
436
-        }
437
-
438
-        if (in_array($name, $this->singleTags)) {
439
-            $this->_xhtml .= '<' . $name;
440
-            $this->_writeAttrs($attrs);
441
-            $this->_xhtml .= ' />';
442
-            return true;
443
-        }
444
-
445
-        // TABLES: cannot open table elements when we are not inside table
446
-        if ((isset($this->_counter['table'])) && ($this->_counter['table'] <= 0)
447
-            && (in_array($name, $this->tableTags)))
448
-        {
449
-            return true;
450
-        }
451
-
452
-        // PARAGRAPHS: close paragraph when closeParagraph tags opening
453
-        if ((in_array($name, $this->closeParagraph)) && (in_array('p', $this->_stack))) {
454
-            $this->_closeHandler($parser, 'p');
455
-        }
456
-
457
-        // LISTS: we should close <li> if <li> of the same level opening
458
-        if ($name == 'li' && count($this->_liStack) &&
459
-            $this->_listScope == $this->_liStack[count($this->_liStack)-1])
460
-        {
461
-            $this->_closeHandler($parser, 'li');
462
-        }
463
-
464
-        // LISTS: we want to know on what nesting level of lists we are
465
-        if (in_array($name, $this->listTags)) {
466
-            $this->_listScope++;
467
-        }
468
-        if ($name == 'li') {
469
-            array_push($this->_liStack, $this->_listScope);
470
-        }
471
-
472
-        $this->_xhtml .= '<' . $name;
473
-        $this->_writeAttrs($attrs);
474
-        $this->_xhtml .= '>';
475
-        array_push($this->_stack,$name);
476
-        $this->_counter[$name] = isset($this->_counter[$name]) ? $this->_counter[$name]+1 : 1;
477
-        return true;
478
-    }
479
-
480
-    /**
481
-     * Closing tag handler - called from HTMLSax
482
-     *
483
-     * @param object $parsers HTML parser
484
-     * @param string $name    tag name
485
-     * @return boolean
486
-     * @access private
487
-     */
488
-    public function _closeHandler(&$parser, $name)
489
-    {
490
-
491
-        $name = strtolower($name);
492
-
493
-        if (isset($this->_dcCounter[$name]) && ($this->_dcCounter[$name] > 0) &&
494
-            (in_array($name, $this->deleteTagsContent)))
495
-        {
496
-           while ($name != ($tag = array_pop($this->_dcStack))) {
497
-            $this->_dcCounter[$tag]--;
498
-           }
499
-
500
-           $this->_dcCounter[$name]--;
501
-        }
502
-
503
-        if (count($this->_dcStack) != 0) {
504
-            return true;
505
-        }
506
-
507
-        if ((isset($this->_counter[$name])) && ($this->_counter[$name] > 0)) {
508
-           while ($name != ($tag = array_pop($this->_stack))) {
509
-               $this->_closeTag($tag);
510
-           }
511
-
512
-           $this->_closeTag($name);
513
-        }
514
-        return true;
515
-    }
516
-
517
-    /**
518
-     * Closes tag
519
-     *
520
-     * @param string $tag tag name
521
-     * @return boolean
522
-     * @access private
523
-     */
524
-    public function _closeTag($tag)
525
-    {
526
-        if (!in_array($tag, $this->noClose)) {
527
-            $this->_xhtml .= '</' . $tag . '>';
528
-        }
529
-
530
-        $this->_counter[$tag]--;
531
-
532
-        if (in_array($tag, $this->listTags)) {
533
-            $this->_listScope--;
534
-        }
535
-
536
-        if ($tag == 'li') {
537
-            array_pop($this->_liStack);
538
-        }
539
-        return true;
540
-    }
541
-
542
-    /**
543
-     * Character data handler - called from HTMLSax
544
-     *
545
-     * @param object $parser HTML parser
546
-     * @param string $data   textual data
547
-     * @return boolean
548
-     * @access private
549
-     */
550
-    public function _dataHandler(&$parser, $data)
551
-    {
552
-        if (count($this->_dcStack) == 0) {
553
-            $this->_xhtml .= $data;
554
-        }
555
-        return true;
556
-    }
557
-
558
-    /**
559
-     * Escape handler - called from HTMLSax
560
-     *
561
-     * @param object $parser HTML parser
562
-     * @param string $data   comments or other type of data
563
-     * @return boolean
564
-     * @access private
565
-     */
566
-    public function _escapeHandler(&$parser, $data)
567
-    {
568
-        return true;
569
-    }
570
-
571
-    /**
572
-     * Returns the XHTML document
573
-     *
574
-     * @return string Processed (X)HTML document
575
-     * @access public
576
-     */
577
-    public function getXHTML ()
578
-    {
579
-        while ($tag = array_pop($this->_stack)) {
580
-            $this->_closeTag($tag);
581
-        }
582
-
583
-        return $this->_xhtml;
584
-    }
585
-
586
-    /**
587
-     * Clears current document data
588
-     *
589
-     * @return boolean
590
-     * @access public
591
-     */
592
-    public function clear()
593
-    {
594
-        $this->_xhtml = '';
595
-        return true;
596
-    }
597
-
598
-    /**
599
-     * Main parsing fuction
600
-     *
601
-     * @param string $doc HTML document for processing
602
-     * @return string Processed (X)HTML document
603
-     * @access public
604
-     */
605
-    public function parse($doc, $isUTF7=false)
606
-    {
60
+	/**
61
+	 * Storage for resulting HTML output
62
+	 *
63
+	 * @var string
64
+	 * @access private
65
+	 */
66
+	private $_xhtml = '';
67
+
68
+	/**
69
+	 * Array of counters for each tag
70
+	 *
71
+	 * @var array
72
+	 * @access private
73
+	 */
74
+	private $_counter = array();
75
+
76
+	/**
77
+	 * Stack of unclosed tags
78
+	 *
79
+	 * @var array
80
+	 * @access private
81
+	 */
82
+	private $_stack = array();
83
+
84
+	/**
85
+	 * Array of counters for tags that must be deleted with all content
86
+	 *
87
+	 * @var array
88
+	 * @access private
89
+	 */
90
+	private $_dcCounter = array();
91
+
92
+	/**
93
+	 * Stack of unclosed tags that must be deleted with all content
94
+	 *
95
+	 * @var array
96
+	 * @access private
97
+	 */
98
+	private $_dcStack = array();
99
+
100
+	/**
101
+	 * Stores level of list (ol/ul) nesting
102
+	 *
103
+	 * @var int
104
+	 * @access private
105
+	 */
106
+	private $_listScope = 0;
107
+
108
+	/**
109
+	 * Stack of unclosed list tags
110
+	 *
111
+	 * @var array
112
+	 * @access private
113
+	 */
114
+	private $_liStack = array();
115
+
116
+	/**
117
+	 * Array of prepared regular expressions for protocols (schemas) matching
118
+	 *
119
+	 * @var array
120
+	 * @access private
121
+	 */
122
+	private $_protoRegexps = array();
123
+
124
+	/**
125
+	 * Array of prepared regular expressions for CSS matching
126
+	 *
127
+	 * @var array
128
+	 * @access private
129
+	 */
130
+	private $_cssRegexps = array();
131
+
132
+	/**
133
+	 * List of single tags ("<tag />")
134
+	 *
135
+	 * @var array
136
+	 * @access public
137
+	 */
138
+	public $singleTags = array('area', 'br', 'img', 'input', 'hr', 'wbr', );
139
+
140
+	/**
141
+	 * List of dangerous tags (such tags will be deleted)
142
+	 *
143
+	 * @var array
144
+	 * @access public
145
+	 */
146
+	public $deleteTags = array(
147
+		'applet', 'base',   'basefont', 'bgsound', 'blink',  'body',
148
+		'embed',  'frame',  'frameset', 'head',    'html',   'ilayer',
149
+		'iframe', 'layer',  'link',     'meta',    'object', 'style',
150
+		'title',  'script',
151
+		);
152
+
153
+	/**
154
+	 * List of dangerous tags (such tags will be deleted, and all content
155
+	 * inside this tags will be also removed)
156
+	 *
157
+	 * @var array
158
+	 * @access public
159
+	 */
160
+	public $deleteTagsContent = array('script', 'style', 'title', 'xml', );
161
+
162
+	/**
163
+	 * Type of protocols filtering ('white' or 'black')
164
+	 *
165
+	 * @var string
166
+	 * @access public
167
+	 */
168
+	public $protocolFiltering = 'white';
169
+
170
+	/**
171
+	 * List of "dangerous" protocols (used for blacklist-filtering)
172
+	 *
173
+	 * @var array
174
+	 * @access public
175
+	 */
176
+	public $blackProtocols = array(
177
+		'about',   'chrome',     'data',       'disk',     'hcp',
178
+		'help',    'javascript', 'livescript', 'lynxcgi',  'lynxexec',
179
+		'ms-help', 'ms-its',     'mhtml',      'mocha',    'opera',
180
+		'res',     'resource',   'shell',      'vbscript', 'view-source',
181
+		'vnd.ms.radio',          'wysiwyg',
182
+		);
183
+
184
+	/**
185
+	 * List of "safe" protocols (used for whitelist-filtering)
186
+	 *
187
+	 * @var array
188
+	 * @access public
189
+	 */
190
+	public $whiteProtocols = array(
191
+		'ed2k',   'file', 'ftp',  'gopher', 'http',  'https',
192
+		'irc',    'mailto', 'news', 'nntp', 'telnet', 'webcal',
193
+		'xmpp',   'callto',
194
+		);
195
+
196
+	/**
197
+	 * List of attributes that can contain protocols
198
+	 *
199
+	 * @var array
200
+	 * @access public
201
+	 */
202
+	public $protocolAttributes = array(
203
+		'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc', 'src',
204
+		);
205
+
206
+	/**
207
+	 * List of dangerous CSS keywords
208
+	 *
209
+	 * Whole style="" attribute will be removed, if parser will find one of
210
+	 * these keywords
211
+	 *
212
+	 * @var array
213
+	 * @access public
214
+	 */
215
+	public $cssKeywords = array(
216
+		'absolute', 'behavior',       'behaviour',   'content', 'expression',
217
+		'fixed',    'include-source', 'moz-binding',
218
+		);
219
+
220
+	/**
221
+	 * List of tags that can have no "closing tag"
222
+	 *
223
+	 * @var array
224
+	 * @access public
225
+	 * @deprecated XHTML does not allow such tags
226
+	 */
227
+	public $noClose = array();
228
+
229
+	/**
230
+	 * List of block-level tags that terminates paragraph
231
+	 *
232
+	 * Paragraph will be closed when this tags opened
233
+	 *
234
+	 * @var array
235
+	 * @access public
236
+	 */
237
+	public $closeParagraph = array(
238
+		'address', 'blockquote', 'center', 'dd',      'dir',       'div',
239
+		'dl',      'dt',         'h1',     'h2',      'h3',        'h4',
240
+		'h5',      'h6',         'hr',     'isindex', 'listing',   'marquee',
241
+		'menu',    'multicol',   'ol',     'p',       'plaintext', 'pre',
242
+		'table',   'ul',         'xmp',
243
+		);
244
+
245
+	/**
246
+	 * List of table tags, all table tags outside a table will be removed
247
+	 *
248
+	 * @var array
249
+	 * @access public
250
+	 */
251
+	public $tableTags = array(
252
+		'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
253
+		'thead',   'tr',
254
+		);
255
+
256
+	/**
257
+	 * List of list tags
258
+	 *
259
+	 * @var array
260
+	 * @access public
261
+	 */
262
+	public $listTags = array('dir', 'menu', 'ol', 'ul', 'dl', );
263
+
264
+	/**
265
+	 * List of dangerous attributes
266
+	 *
267
+	 * @var array
268
+	 * @access public
269
+	 */
270
+	public $attributes = array('dynsrc');
271
+	//public $attributes = array('dynsrc', 'id', 'name', ); //id and name are dangerous?
272
+
273
+	/**
274
+	 * List of allowed "namespaced" attributes
275
+	 *
276
+	 * @var array
277
+	 * @access public
278
+	 */
279
+	public $attributesNS = array('xml:lang', );
280
+
281
+	/**
282
+	 * Constructs class
283
+	 *
284
+	 * @access public
285
+	 */
286
+	public function __construct()
287
+	{
288
+		//making regular expressions based on Proto & CSS arrays
289
+		foreach ($this->blackProtocols as $proto) {
290
+			$preg = "/[\s\x01-\x1F]*";
291
+			for ($i=0; $i<strlen($proto); $i++) {
292
+				$preg .= $proto{$i} . "[\s\x01-\x1F]*";
293
+			}
294
+			$preg .= ":/i";
295
+			$this->_protoRegexps[] = $preg;
296
+		}
297
+
298
+		foreach ($this->cssKeywords as $css) {
299
+			$this->_cssRegexps[] = '/' . $css . '/i';
300
+		}
301
+		return true;
302
+	}
303
+
304
+	/**
305
+	 * Handles the writing of attributes - called from $this->_openHandler()
306
+	 *
307
+	 * @param array $attrs array of attributes $name => $value
308
+	 * @return boolean
309
+	 * @access private
310
+	 */
311
+	private function _writeAttrs ($attrs)
312
+	{
313
+		if (is_array($attrs)) {
314
+			foreach ($attrs as $name => $value) {
315
+
316
+				$name = strtolower($name);
317
+
318
+				if (strpos($name, 'on') === 0) {
319
+					continue;
320
+				}
321
+				if (strpos($name, 'data') === 0) {
322
+					continue;
323
+				}
324
+				if (in_array($name, $this->attributes)) {
325
+					continue;
326
+				}
327
+				if (!preg_match("/^[a-z0-9]+$/i", $name)) {
328
+					if (!in_array($name, $this->attributesNS))
329
+					{
330
+						continue;
331
+					}
332
+				}
333
+
334
+				if (($value === TRUE) || (is_null($value))) {
335
+					$value = $name;
336
+				}
337
+
338
+				if ($name == 'style') {
339
+
340
+				   // removes insignificant backslahes
341
+				   $value = str_replace("\\", '', $value);
342
+
343
+				   // removes CSS comments
344
+				   while (1)
345
+				   {
346
+					 $_value = preg_replace("!/\*.*?\*/!s", '', $value);
347
+					 if ($_value == $value) break;
348
+					 $value = $_value;
349
+				   }
350
+
351
+				   // replace all & to &amp;
352
+				   $value = str_replace('&amp;', '&', $value);
353
+				   $value = str_replace('&', '&amp;', $value);
354
+
355
+				   foreach ($this->_cssRegexps as $css) {
356
+					   if (preg_match($css, $value)) {
357
+						   continue 2;
358
+					   }
359
+				   }
360
+				   foreach ($this->_protoRegexps as $proto) {
361
+					   if (preg_match($proto, $value)) {
362
+						   continue 2;
363
+					   }
364
+				   }
365
+				}
366
+
367
+				$tempval = preg_replace_callback(
368
+						'/&#(\d+);?/m',
369
+						function ($matches) {
370
+							return chr($matches[0]);
371
+						},
372
+						$value
373
+					); //"'
374
+
375
+				$tempval = preg_replace_callback(
376
+						'/&#x([0-9a-f]+);?/mi',
377
+						function ($matches) {
378
+							return chr(hexdec($matches[0]));
379
+						},
380
+						$tempval
381
+					);
382
+
383
+				if ((in_array($name, $this->protocolAttributes)) &&
384
+					(strpos($tempval, ':') !== false))
385
+				{
386
+					if ($this->protocolFiltering == 'black') {
387
+						foreach ($this->_protoRegexps as $proto) {
388
+							if (preg_match($proto, $tempval)) continue 2;
389
+						}
390
+					} else {
391
+						$_tempval = explode(':', $tempval);
392
+						$proto = $_tempval[0];
393
+						if (!in_array($proto, $this->whiteProtocols)) {
394
+							continue;
395
+						}
396
+					}
397
+				}
398
+
399
+				$value = str_replace("\"", "&quot;", $value);
400
+				$this->_xhtml .= ' ' . $name . '="' . $value . '"';
401
+			}
402
+		}
403
+		return true;
404
+	}
405
+
406
+	/**
407
+	 * Opening tag handler - called from HTMLSax
408
+	 *
409
+	 * @param object $parser HTML Parser
410
+	 * @param string $name   tag name
411
+	 * @param array  $attrs  tag attributes
412
+	 * @return boolean
413
+	 * @access private
414
+	 */
415
+	public function _openHandler(&$parser, $name, $attrs)
416
+	{
417
+		$name = strtolower($name);
418
+
419
+		if (in_array($name, $this->deleteTagsContent)) {
420
+			array_push($this->_dcStack, $name);
421
+			$this->_dcCounter[$name] = isset($this->_dcCounter[$name]) ? $this->_dcCounter[$name]+1 : 1;
422
+		}
423
+		if (count($this->_dcStack) != 0) {
424
+			return true;
425
+		}
426
+
427
+		if (in_array($name, $this->deleteTags)) {
428
+			return true;
429
+		}
430
+
431
+		if (!preg_match("/^[a-z0-9]+$/i", $name)) {
432
+			if (preg_match("!(?:\@|://)!i", $name)) {
433
+				$this->_xhtml .= '&lt;' . $name . '&gt;';
434
+			}
435
+			return true;
436
+		}
437
+
438
+		if (in_array($name, $this->singleTags)) {
439
+			$this->_xhtml .= '<' . $name;
440
+			$this->_writeAttrs($attrs);
441
+			$this->_xhtml .= ' />';
442
+			return true;
443
+		}
444
+
445
+		// TABLES: cannot open table elements when we are not inside table
446
+		if ((isset($this->_counter['table'])) && ($this->_counter['table'] <= 0)
447
+			&& (in_array($name, $this->tableTags)))
448
+		{
449
+			return true;
450
+		}
451
+
452
+		// PARAGRAPHS: close paragraph when closeParagraph tags opening
453
+		if ((in_array($name, $this->closeParagraph)) && (in_array('p', $this->_stack))) {
454
+			$this->_closeHandler($parser, 'p');
455
+		}
456
+
457
+		// LISTS: we should close <li> if <li> of the same level opening
458
+		if ($name == 'li' && count($this->_liStack) &&
459
+			$this->_listScope == $this->_liStack[count($this->_liStack)-1])
460
+		{
461
+			$this->_closeHandler($parser, 'li');
462
+		}
463
+
464
+		// LISTS: we want to know on what nesting level of lists we are
465
+		if (in_array($name, $this->listTags)) {
466
+			$this->_listScope++;
467
+		}
468
+		if ($name == 'li') {
469
+			array_push($this->_liStack, $this->_listScope);
470
+		}
471
+
472
+		$this->_xhtml .= '<' . $name;
473
+		$this->_writeAttrs($attrs);
474
+		$this->_xhtml .= '>';
475
+		array_push($this->_stack,$name);
476
+		$this->_counter[$name] = isset($this->_counter[$name]) ? $this->_counter[$name]+1 : 1;
477
+		return true;
478
+	}
479
+
480
+	/**
481
+	 * Closing tag handler - called from HTMLSax
482
+	 *
483
+	 * @param object $parsers HTML parser
484
+	 * @param string $name    tag name
485
+	 * @return boolean
486
+	 * @access private
487
+	 */
488
+	public function _closeHandler(&$parser, $name)
489
+	{
490
+
491
+		$name = strtolower($name);
492
+
493
+		if (isset($this->_dcCounter[$name]) && ($this->_dcCounter[$name] > 0) &&
494
+			(in_array($name, $this->deleteTagsContent)))
495
+		{
496
+		   while ($name != ($tag = array_pop($this->_dcStack))) {
497
+			$this->_dcCounter[$tag]--;
498
+		   }
499
+
500
+		   $this->_dcCounter[$name]--;
501
+		}
502
+
503
+		if (count($this->_dcStack) != 0) {
504
+			return true;
505
+		}
506
+
507
+		if ((isset($this->_counter[$name])) && ($this->_counter[$name] > 0)) {
508
+		   while ($name != ($tag = array_pop($this->_stack))) {
509
+			   $this->_closeTag($tag);
510
+		   }
511
+
512
+		   $this->_closeTag($name);
513
+		}
514
+		return true;
515
+	}
516
+
517
+	/**
518
+	 * Closes tag
519
+	 *
520
+	 * @param string $tag tag name
521
+	 * @return boolean
522
+	 * @access private
523
+	 */
524
+	public function _closeTag($tag)
525
+	{
526
+		if (!in_array($tag, $this->noClose)) {
527
+			$this->_xhtml .= '</' . $tag . '>';
528
+		}
529
+
530
+		$this->_counter[$tag]--;
531
+
532
+		if (in_array($tag, $this->listTags)) {
533
+			$this->_listScope--;
534
+		}
535
+
536
+		if ($tag == 'li') {
537
+			array_pop($this->_liStack);
538
+		}
539
+		return true;
540
+	}
541
+
542
+	/**
543
+	 * Character data handler - called from HTMLSax
544
+	 *
545
+	 * @param object $parser HTML parser
546
+	 * @param string $data   textual data
547
+	 * @return boolean
548
+	 * @access private
549
+	 */
550
+	public function _dataHandler(&$parser, $data)
551
+	{
552
+		if (count($this->_dcStack) == 0) {
553
+			$this->_xhtml .= $data;
554
+		}
555
+		return true;
556
+	}
557
+
558
+	/**
559
+	 * Escape handler - called from HTMLSax
560
+	 *
561
+	 * @param object $parser HTML parser
562
+	 * @param string $data   comments or other type of data
563
+	 * @return boolean
564
+	 * @access private
565
+	 */
566
+	public function _escapeHandler(&$parser, $data)
567
+	{
568
+		return true;
569
+	}
570
+
571
+	/**
572
+	 * Returns the XHTML document
573
+	 *
574
+	 * @return string Processed (X)HTML document
575
+	 * @access public
576
+	 */
577
+	public function getXHTML ()
578
+	{
579
+		while ($tag = array_pop($this->_stack)) {
580
+			$this->_closeTag($tag);
581
+		}
582
+
583
+		return $this->_xhtml;
584
+	}
585
+
586
+	/**
587
+	 * Clears current document data
588
+	 *
589
+	 * @return boolean
590
+	 * @access public
591
+	 */
592
+	public function clear()
593
+	{
594
+		$this->_xhtml = '';
595
+		return true;
596
+	}
597
+
598
+	/**
599
+	 * Main parsing fuction
600
+	 *
601
+	 * @param string $doc HTML document for processing
602
+	 * @return string Processed (X)HTML document
603
+	 * @access public
604
+	 */
605
+	public function parse($doc, $isUTF7=false)
606
+	{
607 607
 	   $this->clear();
608 608
 
609
-       // Save all '<' symbols
610
-       $doc = preg_replace("/<(?=[^a-zA-Z\/\!\?\%])/", '&lt;', (string)$doc);
611
-
612
-       // Web documents shouldn't contains \x00 symbol
613
-       $doc = str_replace("\x00", '', $doc);
614
-
615
-       // Opera6 bug workaround
616
-       $doc = str_replace("\xC0\xBC", '&lt;', $doc);
617
-
618
-       // UTF-7 encoding ASCII decode
619
-       if($isUTF7)
620
-            $doc = $this->repackUTF7($doc);
621
-
622
-       // Instantiate the parser
623
-       $parser= new TSax3();
624
-
625
-       // Set up the parser
626
-       $parser->set_object($this);
627
-
628
-       $parser->set_element_handler('_openHandler','_closeHandler');
629
-       $parser->set_data_handler('_dataHandler');
630
-       $parser->set_escape_handler('_escapeHandler');
631
-
632
-       $parser->parse($doc);
633
-
634
-       return $this->getXHTML();
635
-
636
-    }
637
-
638
-
639
-    /**
640
-     * UTF-7 decoding fuction
641
-     *
642
-     * @param string $str HTML document for recode ASCII part of UTF-7 back to ASCII
643
-     * @return string Decoded document
644
-     * @access private
645
-     */
646
-    private function repackUTF7($str)
647
-    {
648
-       return preg_replace_callback('!\+([0-9a-zA-Z/]+)\-!', array($this, 'repackUTF7Callback'), $str);
649
-    }
650
-
651
-    /**
652
-     * Additional UTF-7 decoding fuction
653
-     *
654
-     * @param string $str String for recode ASCII part of UTF-7 back to ASCII
655
-     * @return string Recoded string
656
-     * @access private
657
-     */
658
-    private function repackUTF7Callback($str)
659
-    {
660
-       $str = base64_decode($str[1]);
661
-       $str = preg_replace_callback('/^((?:\x00.)*)((?:[^\x00].)+)/', array($this, 'repackUTF7Back'), $str);
662
-       return preg_replace('/\x00(.)/', '$1', $str);
663
-    }
664
-
665
-    /**
666
-     * Additional UTF-7 encoding fuction
667
-     *
668
-     * @param string $str String for recode ASCII part of UTF-7 back to ASCII
669
-     * @return string Recoded string
670
-     * @access private
671
-     */
672
-    private function repackUTF7Back($str)
673
-    {
674
-       return $str[1].'+'.rtrim(base64_encode($str[2]), '=').'-';
675
-    }
609
+	   // Save all '<' symbols
610
+	   $doc = preg_replace("/<(?=[^a-zA-Z\/\!\?\%])/", '&lt;', (string)$doc);
611
+
612
+	   // Web documents shouldn't contains \x00 symbol
613
+	   $doc = str_replace("\x00", '', $doc);
614
+
615
+	   // Opera6 bug workaround
616
+	   $doc = str_replace("\xC0\xBC", '&lt;', $doc);
617
+
618
+	   // UTF-7 encoding ASCII decode
619
+	   if($isUTF7)
620
+			$doc = $this->repackUTF7($doc);
621
+
622
+	   // Instantiate the parser
623
+	   $parser= new TSax3();
624
+
625
+	   // Set up the parser
626
+	   $parser->set_object($this);
627
+
628
+	   $parser->set_element_handler('_openHandler','_closeHandler');
629
+	   $parser->set_data_handler('_dataHandler');
630
+	   $parser->set_escape_handler('_escapeHandler');
631
+
632
+	   $parser->parse($doc);
633
+
634
+	   return $this->getXHTML();
635
+
636
+	}
637
+
638
+
639
+	/**
640
+	 * UTF-7 decoding fuction
641
+	 *
642
+	 * @param string $str HTML document for recode ASCII part of UTF-7 back to ASCII
643
+	 * @return string Decoded document
644
+	 * @access private
645
+	 */
646
+	private function repackUTF7($str)
647
+	{
648
+	   return preg_replace_callback('!\+([0-9a-zA-Z/]+)\-!', array($this, 'repackUTF7Callback'), $str);
649
+	}
650
+
651
+	/**
652
+	 * Additional UTF-7 decoding fuction
653
+	 *
654
+	 * @param string $str String for recode ASCII part of UTF-7 back to ASCII
655
+	 * @return string Recoded string
656
+	 * @access private
657
+	 */
658
+	private function repackUTF7Callback($str)
659
+	{
660
+	   $str = base64_decode($str[1]);
661
+	   $str = preg_replace_callback('/^((?:\x00.)*)((?:[^\x00].)+)/', array($this, 'repackUTF7Back'), $str);
662
+	   return preg_replace('/\x00(.)/', '$1', $str);
663
+	}
664
+
665
+	/**
666
+	 * Additional UTF-7 encoding fuction
667
+	 *
668
+	 * @param string $str String for recode ASCII part of UTF-7 back to ASCII
669
+	 * @return string Recoded string
670
+	 * @access private
671
+	 */
672
+	private function repackUTF7Back($str)
673
+	{
674
+	   return $str[1].'+'.rtrim(base64_encode($str[2]), '=').'-';
675
+	}
676 676
 }
677 677
 
678 678
 /*
Please login to merge, or discard this patch.
framework/3rdParty/SafeHtml/HTMLSax3/Decorators.php 1 patch
Indentation   +270 added lines, -270 removed lines patch added patch discarded remove patch
@@ -32,40 +32,40 @@  discard block
 block discarded – undo
32 32
 * @access protected
33 33
 */
34 34
 class TSax3_Trim {
35
-    /**
36
-    * Original handler object
37
-    * @var object
38
-    * @access private
39
-    */
40
-    private $orig_obj;
41
-    /**
42
-    * Original handler method
43
-    * @var string
44
-    * @access private
45
-    */
46
-    private $orig_method;
47
-    /**
48
-    * Constructs TSax3_Trim
49
-    * @param object handler object being decorated
50
-    * @param string original handler method
51
-    * @access protected
52
-    */
53
-    function __construct(&$orig_obj, $orig_method) {
54
-        $this->orig_obj =& $orig_obj;
55
-        $this->orig_method = $orig_method;
56
-    }
57
-    /**
58
-    * Trims the data
59
-    * @param TSax3
60
-    * @param string element data
61
-    * @access protected
62
-    */
63
-    function trimData(&$parser, $data) {
64
-        $data = trim($data);
65
-        if ($data != '') {
66
-            $this->orig_obj->{$this->orig_method}($parser, $data);
67
-        }
68
-    }
35
+	/**
36
+	 * Original handler object
37
+	 * @var object
38
+	 * @access private
39
+	 */
40
+	private $orig_obj;
41
+	/**
42
+	 * Original handler method
43
+	 * @var string
44
+	 * @access private
45
+	 */
46
+	private $orig_method;
47
+	/**
48
+	 * Constructs TSax3_Trim
49
+	 * @param object handler object being decorated
50
+	 * @param string original handler method
51
+	 * @access protected
52
+	 */
53
+	function __construct(&$orig_obj, $orig_method) {
54
+		$this->orig_obj =& $orig_obj;
55
+		$this->orig_method = $orig_method;
56
+	}
57
+	/**
58
+	 * Trims the data
59
+	 * @param TSax3
60
+	 * @param string element data
61
+	 * @access protected
62
+	 */
63
+	function trimData(&$parser, $data) {
64
+		$data = trim($data);
65
+		if ($data != '') {
66
+			$this->orig_obj->{$this->orig_method}($parser, $data);
67
+		}
68
+	}
69 69
 }
70 70
 /**
71 71
 * Coverts tag names to upper case
@@ -73,55 +73,55 @@  discard block
 block discarded – undo
73 73
 * @access protected
74 74
 */
75 75
 class TSax3_CaseFolding {
76
-    /**
77
-    * Original handler object
78
-    * @var object
79
-    * @access private
80
-    */
81
-    private $orig_obj;
82
-    /**
83
-    * Original open handler method
84
-    * @var string
85
-    * @access private
86
-    */
87
-    private $orig_open_method;
88
-    /**
89
-    * Original close handler method
90
-    * @var string
91
-    * @access private
92
-    */
93
-    private $orig_close_method;
94
-    /**
95
-    * Constructs TSax3_CaseFolding
96
-    * @param object handler object being decorated
97
-    * @param string original open handler method
98
-    * @param string original close handler method
99
-    * @access protected
100
-    */
101
-    function __construct(&$orig_obj, $orig_open_method, $orig_close_method) {
102
-        $this->orig_obj =& $orig_obj;
103
-        $this->orig_open_method = $orig_open_method;
104
-        $this->orig_close_method = $orig_close_method;
105
-    }
106
-    /**
107
-    * Folds up open tag callbacks
108
-    * @param TSax3
109
-    * @param string tag name
110
-    * @param array tag attributes
111
-    * @access protected
112
-    */
113
-    function foldOpen(&$parser, $tag, $attrs=array(), $empty = FALSE) {
114
-        $this->orig_obj->{$this->orig_open_method}($parser, strtoupper($tag), $attrs, $empty);
115
-    }
116
-    /**
117
-    * Folds up close tag callbacks
118
-    * @param TSax3
119
-    * @param string tag name
120
-    * @access protected
121
-    */
122
-    function foldClose(&$parser, $tag, $empty = FALSE) {
123
-        $this->orig_obj->{$this->orig_close_method}($parser, strtoupper($tag), $empty);
124
-    }
76
+	/**
77
+	 * Original handler object
78
+	 * @var object
79
+	 * @access private
80
+	 */
81
+	private $orig_obj;
82
+	/**
83
+	 * Original open handler method
84
+	 * @var string
85
+	 * @access private
86
+	 */
87
+	private $orig_open_method;
88
+	/**
89
+	 * Original close handler method
90
+	 * @var string
91
+	 * @access private
92
+	 */
93
+	private $orig_close_method;
94
+	/**
95
+	 * Constructs TSax3_CaseFolding
96
+	 * @param object handler object being decorated
97
+	 * @param string original open handler method
98
+	 * @param string original close handler method
99
+	 * @access protected
100
+	 */
101
+	function __construct(&$orig_obj, $orig_open_method, $orig_close_method) {
102
+		$this->orig_obj =& $orig_obj;
103
+		$this->orig_open_method = $orig_open_method;
104
+		$this->orig_close_method = $orig_close_method;
105
+	}
106
+	/**
107
+	 * Folds up open tag callbacks
108
+	 * @param TSax3
109
+	 * @param string tag name
110
+	 * @param array tag attributes
111
+	 * @access protected
112
+	 */
113
+	function foldOpen(&$parser, $tag, $attrs=array(), $empty = FALSE) {
114
+		$this->orig_obj->{$this->orig_open_method}($parser, strtoupper($tag), $attrs, $empty);
115
+	}
116
+	/**
117
+	 * Folds up close tag callbacks
118
+	 * @param TSax3
119
+	 * @param string tag name
120
+	 * @access protected
121
+	 */
122
+	function foldClose(&$parser, $tag, $empty = FALSE) {
123
+		$this->orig_obj->{$this->orig_close_method}($parser, strtoupper($tag), $empty);
124
+	}
125 125
 }
126 126
 /**
127 127
 * Breaks up data by linefeed characters, resulting in additional
@@ -130,40 +130,40 @@  discard block
 block discarded – undo
130 130
 * @access protected
131 131
 */
132 132
 class TSax3_Linefeed {
133
-    /**
134
-    * Original handler object
135
-    * @var object
136
-    * @access private
137
-    */
138
-    private $orig_obj;
139
-    /**
140
-    * Original handler method
141
-    * @var string
142
-    * @access private
143
-    */
144
-    private $orig_method;
145
-    /**
146
-    * Constructs TSax3_LineFeed
147
-    * @param object handler object being decorated
148
-    * @param string original handler method
149
-    * @access protected
150
-    */
151
-    function __construct(&$orig_obj, $orig_method) {
152
-        $this->orig_obj =& $orig_obj;
153
-        $this->orig_method = $orig_method;
154
-    }
155
-    /**
156
-    * Breaks the data up by linefeeds
157
-    * @param TSax3
158
-    * @param string element data
159
-    * @access protected
160
-    */
161
-    function breakData(&$parser, $data) {
162
-        $data = explode("\n",$data);
163
-        foreach ( $data as $chunk ) {
164
-            $this->orig_obj->{$this->orig_method}($parser, $chunk);
165
-        }
166
-    }
133
+	/**
134
+	 * Original handler object
135
+	 * @var object
136
+	 * @access private
137
+	 */
138
+	private $orig_obj;
139
+	/**
140
+	 * Original handler method
141
+	 * @var string
142
+	 * @access private
143
+	 */
144
+	private $orig_method;
145
+	/**
146
+	 * Constructs TSax3_LineFeed
147
+	 * @param object handler object being decorated
148
+	 * @param string original handler method
149
+	 * @access protected
150
+	 */
151
+	function __construct(&$orig_obj, $orig_method) {
152
+		$this->orig_obj =& $orig_obj;
153
+		$this->orig_method = $orig_method;
154
+	}
155
+	/**
156
+	 * Breaks the data up by linefeeds
157
+	 * @param TSax3
158
+	 * @param string element data
159
+	 * @access protected
160
+	 */
161
+	function breakData(&$parser, $data) {
162
+		$data = explode("\n",$data);
163
+		foreach ( $data as $chunk ) {
164
+			$this->orig_obj->{$this->orig_method}($parser, $chunk);
165
+		}
166
+	}
167 167
 }
168 168
 /**
169 169
 * Breaks up data by tab characters, resulting in additional
@@ -172,40 +172,40 @@  discard block
 block discarded – undo
172 172
 * @access protected
173 173
 */
174 174
 class TSax3_Tab {
175
-    /**
176
-    * Original handler object
177
-    * @var object
178
-    * @access private
179
-    */
180
-    private $orig_obj;
181
-    /**
182
-    * Original handler method
183
-    * @var string
184
-    * @access private
185
-    */
186
-    private $orig_method;
187
-    /**
188
-    * Constructs TSax3_Tab
189
-    * @param object handler object being decorated
190
-    * @param string original handler method
191
-    * @access protected
192
-    */
193
-    function __construct(&$orig_obj, $orig_method) {
194
-        $this->orig_obj =& $orig_obj;
195
-        $this->orig_method = $orig_method;
196
-    }
197
-    /**
198
-    * Breaks the data up by linefeeds
199
-    * @param TSax3
200
-    * @param string element data
201
-    * @access protected
202
-    */
203
-    function breakData(&$parser, $data) {
204
-        $data = explode("\t",$data);
205
-        foreach ( $data as $chunk ) {
206
-            $this->orig_obj->{$this->orig_method}($this, $chunk);
207
-        }
208
-    }
175
+	/**
176
+	 * Original handler object
177
+	 * @var object
178
+	 * @access private
179
+	 */
180
+	private $orig_obj;
181
+	/**
182
+	 * Original handler method
183
+	 * @var string
184
+	 * @access private
185
+	 */
186
+	private $orig_method;
187
+	/**
188
+	 * Constructs TSax3_Tab
189
+	 * @param object handler object being decorated
190
+	 * @param string original handler method
191
+	 * @access protected
192
+	 */
193
+	function __construct(&$orig_obj, $orig_method) {
194
+		$this->orig_obj =& $orig_obj;
195
+		$this->orig_method = $orig_method;
196
+	}
197
+	/**
198
+	 * Breaks the data up by linefeeds
199
+	 * @param TSax3
200
+	 * @param string element data
201
+	 * @access protected
202
+	 */
203
+	function breakData(&$parser, $data) {
204
+		$data = explode("\t",$data);
205
+		foreach ( $data as $chunk ) {
206
+			$this->orig_obj->{$this->orig_method}($this, $chunk);
207
+		}
208
+	}
209 209
 }
210 210
 /**
211 211
 * Breaks up data by XML entities and parses them with html_entity_decode(),
@@ -215,50 +215,50 @@  discard block
 block discarded – undo
215 215
 * @access protected
216 216
 */
217 217
 class TSax3_Entities_Parsed {
218
-    /**
219
-    * Original handler object
220
-    * @var object
221
-    * @access private
222
-    */
223
-    private $orig_obj;
224
-    /**
225
-    * Original handler method
226
-    * @var string
227
-    * @access private
228
-    */
229
-    private $orig_method;
230
-    /**
231
-    * Constructs TSax3_Entities_Parsed
232
-    * @param object handler object being decorated
233
-    * @param string original handler method
234
-    * @access protected
235
-    */
236
-    function __construct(&$orig_obj, $orig_method) {
237
-        $this->orig_obj =& $orig_obj;
238
-        $this->orig_method = $orig_method;
239
-    }
240
-    /**
241
-    * Breaks the data up by XML entities
242
-    * @param TSax3
243
-    * @param string element data
244
-    * @access protected
245
-    */
246
-    function breakData(&$parser, $data) {
247
-        $data = preg_split('/(&.+?;)/',$data,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
248
-        foreach ( $data as $chunk ) {
249
-            $chunk = html_entity_decode($chunk,ENT_NOQUOTES);
250
-            $this->orig_obj->{$this->orig_method}($this, $chunk);
251
-        }
252
-    }
218
+	/**
219
+	 * Original handler object
220
+	 * @var object
221
+	 * @access private
222
+	 */
223
+	private $orig_obj;
224
+	/**
225
+	 * Original handler method
226
+	 * @var string
227
+	 * @access private
228
+	 */
229
+	private $orig_method;
230
+	/**
231
+	 * Constructs TSax3_Entities_Parsed
232
+	 * @param object handler object being decorated
233
+	 * @param string original handler method
234
+	 * @access protected
235
+	 */
236
+	function __construct(&$orig_obj, $orig_method) {
237
+		$this->orig_obj =& $orig_obj;
238
+		$this->orig_method = $orig_method;
239
+	}
240
+	/**
241
+	 * Breaks the data up by XML entities
242
+	 * @param TSax3
243
+	 * @param string element data
244
+	 * @access protected
245
+	 */
246
+	function breakData(&$parser, $data) {
247
+		$data = preg_split('/(&.+?;)/',$data,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
248
+		foreach ( $data as $chunk ) {
249
+			$chunk = html_entity_decode($chunk,ENT_NOQUOTES);
250
+			$this->orig_obj->{$this->orig_method}($this, $chunk);
251
+		}
252
+	}
253 253
 }
254 254
 /**
255 255
 * Compatibility with older PHP versions
256 256
 */
257 257
 if (version_compare(phpversion(), '4.3', '<') && !function_exists('html_entity_decode') ) {
258
-    function html_entity_decode($str, $style=ENT_NOQUOTES) {
259
-        return strtr($str,
260
-            array_flip(get_html_translation_table(HTML_ENTITIES,$style)));
261
-    }
258
+	function html_entity_decode($str, $style=ENT_NOQUOTES) {
259
+		return strtr($str,
260
+			array_flip(get_html_translation_table(HTML_ENTITIES,$style)));
261
+	}
262 262
 }
263 263
 /**
264 264
 * Breaks up data by XML entities but leaves them unparsed,
@@ -267,40 +267,40 @@  discard block
 block discarded – undo
267 267
 * @access protected
268 268
 */
269 269
 class TSax3_Entities_Unparsed {
270
-    /**
271
-    * Original handler object
272
-    * @var object
273
-    * @access private
274
-    */
275
-    private $orig_obj;
276
-    /**
277
-    * Original handler method
278
-    * @var string
279
-    * @access private
280
-    */
281
-    private $orig_method;
282
-    /**
283
-    * Constructs TSax3_Entities_Unparsed
284
-    * @param object handler object being decorated
285
-    * @param string original handler method
286
-    * @access protected
287
-    */
288
-    function __construct(&$orig_obj, $orig_method) {
289
-        $this->orig_obj =& $orig_obj;
290
-        $this->orig_method = $orig_method;
291
-    }
292
-    /**
293
-    * Breaks the data up by XML entities
294
-    * @param TSax3
295
-    * @param string element data
296
-    * @access protected
297
-    */
298
-    function breakData(&$parser, $data) {
299
-        $data = preg_split('/(&.+?;)/',$data,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
300
-        foreach ( $data as $chunk ) {
301
-            $this->orig_obj->{$this->orig_method}($this, $chunk);
302
-        }
303
-    }
270
+	/**
271
+	 * Original handler object
272
+	 * @var object
273
+	 * @access private
274
+	 */
275
+	private $orig_obj;
276
+	/**
277
+	 * Original handler method
278
+	 * @var string
279
+	 * @access private
280
+	 */
281
+	private $orig_method;
282
+	/**
283
+	 * Constructs TSax3_Entities_Unparsed
284
+	 * @param object handler object being decorated
285
+	 * @param string original handler method
286
+	 * @access protected
287
+	 */
288
+	function __construct(&$orig_obj, $orig_method) {
289
+		$this->orig_obj =& $orig_obj;
290
+		$this->orig_method = $orig_method;
291
+	}
292
+	/**
293
+	 * Breaks the data up by XML entities
294
+	 * @param TSax3
295
+	 * @param string element data
296
+	 * @access protected
297
+	 */
298
+	function breakData(&$parser, $data) {
299
+		$data = preg_split('/(&.+?;)/',$data,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
300
+		foreach ( $data as $chunk ) {
301
+			$this->orig_obj->{$this->orig_method}($this, $chunk);
302
+		}
303
+	}
304 304
 }
305 305
 
306 306
 /**
@@ -310,52 +310,52 @@  discard block
 block discarded – undo
310 310
 * @access protected
311 311
 */
312 312
 class TSax3_Escape_Stripper {
313
-    /**
314
-    * Original handler object
315
-    * @var object
316
-    * @access private
317
-    */
318
-    private $orig_obj;
319
-    /**
320
-    * Original handler method
321
-    * @var string
322
-    * @access private
323
-    */
324
-    private $orig_method;
325
-    /**
326
-    * Constructs TSax3_Entities_Unparsed
327
-    * @param object handler object being decorated
328
-    * @param string original handler method
329
-    * @access protected
330
-    */
331
-    function __construct(&$orig_obj, $orig_method) {
332
-        $this->orig_obj =& $orig_obj;
333
-        $this->orig_method = $orig_method;
334
-    }
335
-    /**
336
-    * Breaks the data up by XML entities
337
-    * @param TSax3
338
-    * @param string element data
339
-    * @access protected
340
-    */
341
-    function strip(&$parser, $data) {
342
-        // Check for HTML comments first
343
-        if ( substr($data,0,2) == '--' ) {
344
-            $patterns = array(
345
-                '/^\-\-/',          // Opening comment: --
346
-                '/\-\-$/',          // Closing comment: --
347
-            );
348
-            $data = preg_replace($patterns,'',$data);
313
+	/**
314
+	 * Original handler object
315
+	 * @var object
316
+	 * @access private
317
+	 */
318
+	private $orig_obj;
319
+	/**
320
+	 * Original handler method
321
+	 * @var string
322
+	 * @access private
323
+	 */
324
+	private $orig_method;
325
+	/**
326
+	 * Constructs TSax3_Entities_Unparsed
327
+	 * @param object handler object being decorated
328
+	 * @param string original handler method
329
+	 * @access protected
330
+	 */
331
+	function __construct(&$orig_obj, $orig_method) {
332
+		$this->orig_obj =& $orig_obj;
333
+		$this->orig_method = $orig_method;
334
+	}
335
+	/**
336
+	 * Breaks the data up by XML entities
337
+	 * @param TSax3
338
+	 * @param string element data
339
+	 * @access protected
340
+	 */
341
+	function strip(&$parser, $data) {
342
+		// Check for HTML comments first
343
+		if ( substr($data,0,2) == '--' ) {
344
+			$patterns = array(
345
+				'/^\-\-/',          // Opening comment: --
346
+				'/\-\-$/',          // Closing comment: --
347
+			);
348
+			$data = preg_replace($patterns,'',$data);
349 349
 
350
-        // Check for XML CDATA sections (note: don't do both!)
351
-        } else if ( substr($data,0,1) == '[' ) {
352
-            $patterns = array(
353
-                '/^\[.*CDATA.*\[/s', // Opening CDATA
354
-                '/\].*\]$/s',       // Closing CDATA
355
-                );
356
-            $data = preg_replace($patterns,'',$data);
357
-        }
350
+		// Check for XML CDATA sections (note: don't do both!)
351
+		} else if ( substr($data,0,1) == '[' ) {
352
+			$patterns = array(
353
+				'/^\[.*CDATA.*\[/s', // Opening CDATA
354
+				'/\].*\]$/s',       // Closing CDATA
355
+				);
356
+			$data = preg_replace($patterns,'',$data);
357
+		}
358 358
 
359
-        $this->orig_obj->{$this->orig_method}($this, $data);
360
-    }
359
+		$this->orig_obj->{$this->orig_method}($this, $data);
360
+	}
361 361
 }
Please login to merge, or discard this patch.