This file is indexed.

/usr/share/php/Config/Container/IniCommented.php is in php-config 1.10.12-4.

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
<?php
// +----------------------------------------------------------------------+
// | PHP Version 4                                                        |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group                                |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.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/2_02.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.               |
// +----------------------------------------------------------------------+
// | Author: Bertrand Mansion <bmansion@mamasam.com>                      |
// +----------------------------------------------------------------------+
//
// $Id: IniCommented.php 306554 2010-12-21 20:04:20Z cweiske $

/**
* Config parser for PHP .ini files with comments
*
* @author      Bertrand Mansion <bmansion@mamasam.com>
* @package     Config
*/
class Config_Container_IniCommented {

    /**
     * Options for this class:
     * - linebreak - Character to use as new line break when serializing
     *
     * @var array
     */
    var $options = array(
        'linebreak' => "\n"
    );

    /**
    * Constructor
    *
    * @access public
    * @param    string  $options    (optional)Options to be used by renderer
    */
    function Config_Container_IniCommented($options = array())
    {
        $this->options = array_merge($this->options, $options);
    } // end constructor

    /**
    * Parses the data of the given configuration file
    *
    * @access public
    * @param string $datasrc    path to the configuration file
    * @param object $obj        reference to a config object
    * @return mixed returns a PEAR_ERROR, if error occurs or true if ok
    */
    function &parseDatasrc($datasrc, &$obj)
    {
        $return = true;
        if (!file_exists($datasrc)) {
            return PEAR::raiseError(
                'Datasource file does not exist.',
                null, PEAR_ERROR_RETURN
            );
        }
        $lines = file($datasrc);
        if ($lines === false) {
            return PEAR::raiseError(
                'File could not be read',
                null, PEAR_ERROR_RETURN
            );
        }

        $n = 0;
        $lastline = '';
        $currentSection =& $obj->container;
        foreach ($lines as $line) {
            $n++;
            if (preg_match('/^\s*;(.*?)\s*$/', $line, $match)) {
                // a comment
                $currentSection->createComment($match[1]);
            } elseif (preg_match('/^\s*$/', $line)) {
                // a blank line
                $currentSection->createBlank();
            } elseif (preg_match('/^\s*([a-zA-Z0-9_\-\.\s:]*)\s*=\s*(.*)\s*$/', $line, $match)) {
                // a directive
                
                $values = $this->_quoteAndCommaParser($match[2]);
                if (PEAR::isError($values)) {
                    return PEAR::raiseError($values);
                }
                
                if (count($values)) {
                    foreach($values as $value) {
                        if ($value[0] == 'normal') {
                            $currentSection->createDirective(trim($match[1]), $value[1]);
                        }
                        if ($value[0] == 'comment') {
                            $currentSection->createComment(substr($value[1], 1));
                        }
                    }
                }
            } elseif (preg_match('/^\s*\[\s*(.*)\s*\]\s*$/', $line, $match)) {
                // a section
                $currentSection =& $obj->container->createSection($match[1]);
            } else {
                return PEAR::raiseError("Syntax error in '$datasrc' at line $n.", null, PEAR_ERROR_RETURN);
            }
        }
        return $return;
    } // end func parseDatasrc

    /**
     * Quote and Comma Parser for INI files
     *
     * This function allows complex values such as:
     *
     * <samp>
     * mydirective = "Item, number \"1\"", Item 2 ; "This" is really, really tricky
     * </samp>
     * @param  string  $text    value of a directive to parse for quotes/multiple values
     * @return array   The array returned contains multiple values, if any (unquoted literals
     *                 to be used as is), and a comment, if any.  The format of the array is:
     *
     * <pre>
     * array(array('normal', 'first value'),
     *       array('normal', 'next value'),...
     *       array('comment', '; comment with leading ;'))
     * </pre>
     * @author Greg Beaver <cellog@users.sourceforge.net>
     * @access private
     */
    function _quoteAndCommaParser($text)
    {   
        $text = trim($text);
        if ($text == '') {
            $emptyNode = array();
            $emptyNode[0][0] = 'normal';
            $emptyNode[0][1] = '';
            return $emptyNode;
        }

        // tokens
        $tokens['normal'] = array('"', ';', ',');
        $tokens['quote'] = array('"', '\\');
        $tokens['escape'] = false; // cycle
        $tokens['after_quote'] = array(',', ';');
        
        // events
        $events['normal'] = array('"' => 'quote', ';' => 'comment', ',' => 'normal');
        $events['quote'] = array('"' => 'after_quote', '\\' => 'escape');
        $events['after_quote'] = array(',' => 'normal', ';' => 'comment');
        
        // state stack
        $stack = array();

        // return information
        $return = array();
        $returnpos = 0;
        $returntype = 'normal';

        // initialize
        array_push($stack, 'normal');
        $pos = 0; // position in $text

        do {
            $char = $text{$pos};
            $state = $this->_getQACEvent($stack);

            if ($tokens[$state]) {
                if (in_array($char, $tokens[$state])) {
                    switch($events[$state][$char]) {
                        case 'quote' :
                            if ($state == 'normal' &&
                                isset($return[$returnpos]) &&
                                !empty($return[$returnpos][1])) {
                                return PEAR::raiseError(
                                    'invalid ini syntax, quotes cannot follow'
                                    . " text '$text'",
                                    null, PEAR_ERROR_RETURN
                                );
                            }
                            if ($returnpos >= 0 && isset($return[$returnpos])) {
                                // trim any unnecessary whitespace in earlier entries
                                $return[$returnpos][1] = trim($return[$returnpos][1]);
                            } else {
                                $returnpos++;
                            }
                            $return[$returnpos] = array('normal', '');
                            array_push($stack, 'quote');
                            continue 2;
                        break;
                        case 'comment' :
                            // comments go to the end of the line, so we are done
                            $return[++$returnpos] = array('comment', substr($text, $pos));
                            return $return;
                        break;
                        case 'after_quote' :
                            array_push($stack, 'after_quote');
                        break;
                        case 'escape' :
                            // don't save the first slash
                            array_push($stack, 'escape');
                            continue 2;
                        break;
                        case 'normal' :
                        // start a new segment
                            if ($state == 'normal') {
                                $returnpos++;
                                continue 2;
                            } else {
                                while ($state != 'normal') {
                                    array_pop($stack);
                                    $state = $this->_getQACEvent($stack);
                                }
                                $returnpos++;
                            }
                        break;
                        default :
                            PEAR::raiseError(
                                "::_quoteAndCommaParser oops, state missing",
                                null, PEAR_ERROR_DIE
                            );
                        break;
                    }
                } else {
                    if ($state != 'after_quote') {
                        if (!isset($return[$returnpos])) {
                            $return[$returnpos] = array('normal', '');
                        }
                        // add this character to the current ini segment if
                        // non-empty, or if in a quote
                        if ($state == 'quote') {
                            $return[$returnpos][1] .= $char;
                        } elseif (!empty($return[$returnpos][1]) ||
                                 (empty($return[$returnpos][1]) && trim($char) != '')) {
                            if (!isset($return[$returnpos])) {
                                $return[$returnpos] = array('normal', '');
                            }
                            $return[$returnpos][1] .= $char;
                            if (strcasecmp('true', $return[$returnpos][1]) == 0) {
                              $return[$returnpos][1] = '1';
                            } elseif (strcasecmp('false', $return[$returnpos][1]) == 0) {
                              $return[$returnpos][1] = '';
                            }
                        }
                    } else {
                        if (trim($char) != '') {
                            return PEAR::raiseError(
                                'invalid ini syntax, text after a quote'
                                . " not allowed '$text'",
                                null, PEAR_ERROR_RETURN
                            );
                        }
                    }
                }
            } else {
                // no tokens, so add this one and cycle to previous state
                $return[$returnpos][1] .= $char;
                array_pop($stack);
            }
        } while (++$pos < strlen($text));
        return $return;
    } // end func _quoteAndCommaParser
    
    /**
     * Retrieve the state off of a state stack for the Quote and Comma Parser
     * @param  array  $stack    The parser state stack
     * @author Greg Beaver <cellog@users.sourceforge.net>
     * @access private
     */
    function _getQACEvent($stack)
    {
        return array_pop($stack);
    } // end func _getQACEvent

    /**
    * Returns a formatted string of the object
    * @param    object  $obj    Container object to be output as string
    * @access   public
    * @return   string
    */
    function toString(&$obj)
    {
        static $childrenCount, $commaString;

        if (!isset($string)) {
            $string = '';
        }
        switch ($obj->type) {
            case 'blank':
                $string = $this->options['linebreak'];
                break;
            case 'comment':
                $string = ';'.$obj->content . $this->options['linebreak'];
                break;
            case 'directive':
                $count = $obj->parent->countChildren('directive', $obj->name);
                $content = $obj->content;
                if ($content === false) {
                    $content = '0';
                } elseif ($content === true) {
                    $content = '1';
                } elseif (strlen(trim($content)) < strlen($content) ||
                          strpos($content, ',') !== false ||
                          strpos($content, ';') !== false ||
                          strpos($content, '=') !== false ||
                          strpos($content, '"') !== false ||
                          strpos($content, '%') !== false ||
                          strpos($content, '~') !== false ||
													strpos($content, '!') !== false ||
													strpos($content, '|') !== false ||
													strpos($content, '&') !== false ||
													strpos($content, '(') !== false ||
													strpos($content, ')') !== false ||
													$content === 'none') {
                    $content = '"'.addslashes($content).'"';          
                }
                if ($count > 1) {
                    // multiple values for a directive are separated by a comma
                    if (isset($childrenCount[$obj->name])) {
                        $childrenCount[$obj->name]++;
                    } else {
                        $childrenCount[$obj->name] = 0;
                        $commaString[$obj->name] = $obj->name.' = ';
                    }
                    if ($childrenCount[$obj->name] == $count-1) {
                        // Clean the static for future calls to toString
                        $string .= $commaString[$obj->name] . $content
                            . $this->options['linebreak'];
                        unset($childrenCount[$obj->name]);
                        unset($commaString[$obj->name]);
                    } else {
                        $commaString[$obj->name] .= $content.', ';
                    }
                } else {
                    $string = $obj->name.' = '.$content . $this->options['linebreak'];
                }
                break;
            case 'section':
                if (!$obj->isRoot()) {
                    $string = '[' . $obj->name . ']' . $this->options['linebreak'];
                }
                if (count($obj->children) > 0) {
                    for ($i = 0; $i < count($obj->children); $i++) {
                        $string .= $this->toString($obj->getChild($i));
                    }
                }
                break;
            default:
                $string = '';
        }
        return $string;
    } // end func toString
} // end class Config_Container_IniCommented
?>