This file is indexed.

/usr/share/php/XML/Parser/Simple.php is in php-xml-parser 1.3.4-7.

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
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
 * XML_Parser
 *
 * XML Parser's Simple parser class 
 *
 * PHP versions 4 and 5
 *
 * LICENSE:
 *
 * Copyright (c) 2002-2008 The PHP Group
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *    * Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *    * Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *    * The name of the author may not be used to endorse or promote products
 *      derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * @category  XML
 * @package   XML_Parser
 * @author    Stephan Schmidt <schst@php.net>
 * @copyright 2004-2008 Stephan Schmidt <schst@php.net>
 * @license   http://opensource.org/licenses/bsd-license New BSD License
 * @version   CVS: $Id: Simple.php 265444 2008-08-24 21:48:21Z ashnazg $
 * @link      http://pear.php.net/package/XML_Parser
 */

/**
 * built on XML_Parser
 */
require_once 'XML/Parser.php';

/**
 * Simple XML parser class.
 *
 * This class is a simplified version of XML_Parser.
 * In most XML applications the real action is executed,
 * when a closing tag is found.
 *
 * XML_Parser_Simple allows you to just implement one callback
 * for each tag that will receive the tag with its attributes
 * and CData.
 *
 * <code>
 * require_once '../Parser/Simple.php';
 *
 * class myParser extends XML_Parser_Simple
 * {
 *     function myParser()
 *     {
 *        $this->XML_Parser_Simple();
 *      }
 * 
 *    function handleElement($name, $attribs, $data)
 *     {
 *         printf('handle %s<br>', $name);
 *     }
 * }
 * 
 * $p = &new myParser();
 * 
 * $result = $p->setInputFile('myDoc.xml');
 * $result = $p->parse();
 * </code>
 *
 * @category  XML
 * @package   XML_Parser
 * @author    Stephan Schmidt <schst@php.net>
 * @copyright 2004-2008 The PHP Group
 * @license   http://opensource.org/licenses/bsd-license New BSD License
 * @version   Release: @package_version@
 * @link      http://pear.php.net/package/XML_Parser
 */
class XML_Parser_Simple extends XML_Parser
{
    /**
     * element stack
     *
     * @access   private
     * @var      array
     */
    var $_elStack = array();

    /**
     * all character data
     *
     * @access   private
     * @var      array
     */
    var $_data = array();

    /**
     * element depth
     *
     * @access   private
     * @var      integer
     */
    var $_depth = 0;

    /**
     * Mapping from expat handler function to class method.
     *
     * @var  array
     */
    var $handler = array(
        'default_handler'                   => 'defaultHandler',
        'processing_instruction_handler'    => 'piHandler',
        'unparsed_entity_decl_handler'      => 'unparsedHandler',
        'notation_decl_handler'             => 'notationHandler',
        'external_entity_ref_handler'       => 'entityrefHandler'
    );
    
    /**
     * Creates an XML parser.
     *
     * This is needed for PHP4 compatibility, it will
     * call the constructor, when a new instance is created.
     *
     * @param string $srcenc source charset encoding, use NULL (default) to use
     *                       whatever the document specifies
     * @param string $mode   how this parser object should work, "event" for
     *                       handleElement(), "func" to have it call functions
     *                       named after elements (handleElement_$name())
     * @param string $tgtenc a valid target encoding
     */
    function XML_Parser_Simple($srcenc = null, $mode = 'event', $tgtenc = null)
    {
        $this->XML_Parser($srcenc, $mode, $tgtenc);
    }

    /**
     * inits the handlers
     *
     * @return mixed
     * @access private
     */
    function _initHandlers()
    {
        if (!is_object($this->_handlerObj)) {
            $this->_handlerObj = &$this;
        }

        if ($this->mode != 'func' && $this->mode != 'event') {
            return $this->raiseError('Unsupported mode given', 
                XML_PARSER_ERROR_UNSUPPORTED_MODE);
        }
        xml_set_object($this->parser, $this->_handlerObj);

        xml_set_element_handler($this->parser, array(&$this, 'startHandler'), 
            array(&$this, 'endHandler'));
        xml_set_character_data_handler($this->parser, array(&$this, 'cdataHandler'));
        
        /**
         * set additional handlers for character data, entities, etc.
         */
        foreach ($this->handler as $xml_func => $method) {
            if (method_exists($this->_handlerObj, $method)) {
                $xml_func = 'xml_set_' . $xml_func;
                $xml_func($this->parser, $method);
            }
        }
    }

    /**
     * Reset the parser.
     *
     * This allows you to use one parser instance
     * to parse multiple XML documents.
     *
     * @access   public
     * @return   boolean|object     true on success, PEAR_Error otherwise
     */
    function reset()
    {
        $this->_elStack = array();
        $this->_data    = array();
        $this->_depth   = 0;
        
        $result = $this->_create();
        if ($this->isError($result)) {
            return $result;
        }
        return true;
    }

    /**
     * start handler
     *
     * Pushes attributes and tagname onto a stack
     *
     * @param resource $xp       xml parser resource
     * @param string   $elem     element name
     * @param array    &$attribs attributes
     *
     * @return mixed
     * @access private
     * @final
     */
    function startHandler($xp, $elem, &$attribs)
    {
        array_push($this->_elStack, array(
            'name'    => $elem,
            'attribs' => $attribs
        ));
        $this->_depth++;
        $this->_data[$this->_depth] = '';
    }

    /**
     * end handler
     *
     * Pulls attributes and tagname from a stack
     *
     * @param resource $xp   xml parser resource
     * @param string   $elem element name
     *
     * @return mixed
     * @access private
     * @final
     */
    function endHandler($xp, $elem)
    {
        $el   = array_pop($this->_elStack);
        $data = $this->_data[$this->_depth];
        $this->_depth--;

        switch ($this->mode) {
        case 'event':
            $this->_handlerObj->handleElement($el['name'], $el['attribs'], $data);
            break;
        case 'func':
            $func = 'handleElement_' . $elem;
            if (strchr($func, '.')) {
                $func = str_replace('.', '_', $func);
            }
            if (method_exists($this->_handlerObj, $func)) {
                call_user_func(array(&$this->_handlerObj, $func), 
                    $el['name'], $el['attribs'], $data);
            }
            break;
        }
    }

    /**
     * handle character data
     *
     * @param resource $xp   xml parser resource
     * @param string   $data data
     *
     * @return void
     * @access private
     * @final
     */
    function cdataHandler($xp, $data)
    {
        $this->_data[$this->_depth] .= $data;
    }

    /**
     * handle a tag
     *
     * Implement this in your parser 
     *
     * @param string $name    element name
     * @param array  $attribs attributes
     * @param string $data    character data
     *
     * @return void
     * @access public
     * @abstract
     */
    function handleElement($name, $attribs, $data)
    {
    }

    /**
     * get the current tag depth
     *
     * The root tag is in depth 0.
     *
     * @access   public
     * @return   integer
     */
    function getCurrentDepth()
    {
        return $this->_depth;
    }

    /**
     * add some string to the current ddata.
     *
     * This is commonly needed, when a document is parsed recursively.
     *
     * @param string $data data to add
     *
     * @return void
     * @access public
     */
    function addToData($data)
    {
        $this->_data[$this->_depth] .= $data;
    }
}
?>