/usr/share/php/XML/HTMLSax3/Decorators.php is in php-xml-htmlsax3 3.0.0+really3.0.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | <?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
//
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject toversion 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Alexander Zhukov <alex@veresk.ru> Original port from Python |
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> Port to PEAR + more |
// | Authors: Many @ Sitepointforums Advanced PHP Forums |
// +----------------------------------------------------------------------+
//
// $Id: Decorators.php,v 1.2 2007/10/29 21:41:35 hfuecks Exp $
//
/**
* Decorators for dealing with parser options
* @package XML_HTMLSax3
* @version $Id: Decorators.php,v 1.2 2007/10/29 21:41:35 hfuecks Exp $
* @see XML_HTMLSax3::set_option
*/
/**
* Trims the contents of element data from whitespace at start and end
* @package XML_HTMLSax3
* @access protected
*/
class XML_HTMLSax3_Trim {
/**
* Original handler object
* @var object
* @access private
*/
var $orig_obj;
/**
* Original handler method
* @var string
* @access private
*/
var $orig_method;
/**
* Constructs XML_HTMLSax3_Trim
* @param object handler object being decorated
* @param string original handler method
* @access protected
*/
function XML_HTMLSax3_Trim($orig_obj, $orig_method) {
$this->orig_obj = $orig_obj;
$this->orig_method = $orig_method;
}
/**
* Trims the data
* @param XML_HTMLSax3
* @param string element data
* @access protected
*/
function trimData($parser, $data) {
$data = trim($data);
if ($data != '') {
$this->orig_obj->{$this->orig_method}($parser, $data);
}
}
}
/**
* Coverts tag names to upper case
* @package XML_HTMLSax3
* @access protected
*/
class XML_HTMLSax3_CaseFolding {
/**
* Original handler object
* @var object
* @access private
*/
var $orig_obj;
/**
* Original open handler method
* @var string
* @access private
*/
var $orig_open_method;
/**
* Original close handler method
* @var string
* @access private
*/
var $orig_close_method;
/**
* Constructs XML_HTMLSax3_CaseFolding
* @param object handler object being decorated
* @param string original open handler method
* @param string original close handler method
* @access protected
*/
function XML_HTMLSax3_CaseFolding($orig_obj, $orig_open_method, $orig_close_method) {
$this->orig_obj = $orig_obj;
$this->orig_open_method = $orig_open_method;
$this->orig_close_method = $orig_close_method;
}
/**
* Folds up open tag callbacks
* @param XML_HTMLSax3
* @param string tag name
* @param array tag attributes
* @access protected
*/
function foldOpen($parser, $tag, $attrs=array(), $empty = FALSE) {
$this->orig_obj->{$this->orig_open_method}($parser, strtoupper($tag), $attrs, $empty);
}
/**
* Folds up close tag callbacks
* @param XML_HTMLSax3
* @param string tag name
* @access protected
*/
function foldClose($parser, $tag, $empty = FALSE) {
$this->orig_obj->{$this->orig_close_method}($parser, strtoupper($tag), $empty);
}
}
/**
* Breaks up data by linefeed characters, resulting in additional
* calls to the data handler
* @package XML_HTMLSax3
* @access protected
*/
class XML_HTMLSax3_Linefeed {
/**
* Original handler object
* @var object
* @access private
*/
var $orig_obj;
/**
* Original handler method
* @var string
* @access private
*/
var $orig_method;
/**
* Constructs XML_HTMLSax3_LineFeed
* @param object handler object being decorated
* @param string original handler method
* @access protected
*/
function XML_HTMLSax3_LineFeed($orig_obj, $orig_method) {
$this->orig_obj = $orig_obj;
$this->orig_method = $orig_method;
}
/**
* Breaks the data up by linefeeds
* @param XML_HTMLSax3
* @param string element data
* @access protected
*/
function breakData($parser, $data) {
$data = explode("\n",$data);
foreach ( $data as $chunk ) {
$this->orig_obj->{$this->orig_method}($parser, $chunk);
}
}
}
/**
* Breaks up data by tab characters, resulting in additional
* calls to the data handler
* @package XML_HTMLSax3
* @access protected
*/
class XML_HTMLSax3_Tab {
/**
* Original handler object
* @var object
* @access private
*/
var $orig_obj;
/**
* Original handler method
* @var string
* @access private
*/
var $orig_method;
/**
* Constructs XML_HTMLSax3_Tab
* @param object handler object being decorated
* @param string original handler method
* @access protected
*/
function XML_HTMLSax3_Tab($orig_obj, $orig_method) {
$this->orig_obj = $orig_obj;
$this->orig_method = $orig_method;
}
/**
* Breaks the data up by linefeeds
* @param XML_HTMLSax3
* @param string element data
* @access protected
*/
function breakData($parser, $data) {
$data = explode("\t",$data);
foreach ( $data as $chunk ) {
$this->orig_obj->{$this->orig_method}($this, $chunk);
}
}
}
/**
* Breaks up data by XML entities and parses them with html_entity_decode(),
* resulting in additional calls to the data handler<br />
* Requires PHP 4.3.0+
* @package XML_HTMLSax3
* @access protected
*/
class XML_HTMLSax3_Entities_Parsed {
/**
* Original handler object
* @var object
* @access private
*/
var $orig_obj;
/**
* Original handler method
* @var string
* @access private
*/
var $orig_method;
/**
* Constructs XML_HTMLSax3_Entities_Parsed
* @param object handler object being decorated
* @param string original handler method
* @access protected
*/
function XML_HTMLSax3_Entities_Parsed($orig_obj, $orig_method) {
$this->orig_obj = $orig_obj;
$this->orig_method = $orig_method;
}
/**
* Breaks the data up by XML entities
* @param XML_HTMLSax3
* @param string element data
* @access protected
*/
function breakData($parser, $data) {
$data = preg_split('/(&.+?;)/',$data,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
foreach ( $data as $chunk ) {
$chunk = html_entity_decode($chunk,ENT_NOQUOTES);
$this->orig_obj->{$this->orig_method}($this, $chunk);
}
}
}
/**
* Compatibility with older PHP versions
*/
if (version_compare(phpversion(), '4.3', '<') && !function_exists('html_entity_decode') ) {
function html_entity_decode($str, $style=ENT_NOQUOTES) {
return strtr($str,
array_flip(get_html_translation_table(HTML_ENTITIES,$style)));
}
}
/**
* Breaks up data by XML entities but leaves them unparsed,
* resulting in additional calls to the data handler<br />
* @package XML_HTMLSax3
* @access protected
*/
class XML_HTMLSax3_Entities_Unparsed {
/**
* Original handler object
* @var object
* @access private
*/
var $orig_obj;
/**
* Original handler method
* @var string
* @access private
*/
var $orig_method;
/**
* Constructs XML_HTMLSax3_Entities_Unparsed
* @param object handler object being decorated
* @param string original handler method
* @access protected
*/
function XML_HTMLSax3_Entities_Unparsed($orig_obj, $orig_method) {
$this->orig_obj = $orig_obj;
$this->orig_method = $orig_method;
}
/**
* Breaks the data up by XML entities
* @param XML_HTMLSax3
* @param string element data
* @access protected
*/
function breakData($parser, $data) {
$data = preg_split('/(&.+?;)/',$data,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
foreach ( $data as $chunk ) {
$this->orig_obj->{$this->orig_method}($this, $chunk);
}
}
}
/**
* Strips the HTML comment markers or CDATA sections from an escape.
* If XML_OPTIONS_FULL_ESCAPES is on, this decorator is not used.<br />
* @package XML_HTMLSax3
* @access protected
*/
class XML_HTMLSax3_Escape_Stripper {
/**
* Original handler object
* @var object
* @access private
*/
var $orig_obj;
/**
* Original handler method
* @var string
* @access private
*/
var $orig_method;
/**
* Constructs XML_HTMLSax3_Entities_Unparsed
* @param object handler object being decorated
* @param string original handler method
* @access protected
*/
function XML_HTMLSax3_Escape_Stripper($orig_obj, $orig_method) {
$this->orig_obj = $orig_obj;
$this->orig_method = $orig_method;
}
/**
* Breaks the data up by XML entities
* @param XML_HTMLSax3
* @param string element data
* @access protected
*/
function strip($parser, $data) {
// Check for HTML comments first
if ( substr($data,0,2) == '--' ) {
$patterns = array(
'/^\-\-/', // Opening comment: --
'/\-\-$/', // Closing comment: --
);
$data = preg_replace($patterns,'',$data);
// Check for XML CDATA sections (note: don't do both!)
} else if ( substr($data,0,1) == '[' ) {
$patterns = array(
'/^\[.*CDATA.*\[/s', // Opening CDATA
'/\].*\]$/s', // Closing CDATA
);
$data = preg_replace($patterns,'',$data);
}
$this->orig_obj->{$this->orig_method}($this, $data);
}
}
|