This file is indexed.

/usr/share/php/Horde/View/Helper/Tag.php is in php-horde-view 2.0.3-1.

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
<?php
/**
 * Copyright 2007-2008 Maintainable Software, LLC
 * Copyright 2008-2013 Horde LLC (http://www.horde.org/)
 *
 * @author     Mike Naberezny <mike@maintainable.com>
 * @author     Derek DeVries <derek@maintainable.com>
 * @author     Chuck Hagenbuch <chuck@horde.org>
 * @license    http://www.horde.org/licenses/bsd
 * @category   Horde
 * @package    View
 * @subpackage Helper
 */

/**
 * Use these methods to generate HTML tags programmatically.
 *
 * By default, they output HTML 4.01 Strict compliant tags.
 *
 * @author     Mike Naberezny <mike@maintainable.com>
 * @author     Derek DeVries <derek@maintainable.com>
 * @author     Chuck Hagenbuch <chuck@horde.org>
 * @license    http://www.horde.org/licenses/bsd
 * @category   Horde
 * @package    View
 * @subpackage Helper
 */
class Horde_View_Helper_Tag extends Horde_View_Helper_Base
{
    /**
     * Boolean HTML attributes.
     *
     * @var array
     */
    private $_booleanAttributes = array('checked', 'disabled', 'multiple', 'readonly', 'selected');

    /**
     * Returns an empty HTML tag of type $name.
     *
     * Add HTML attributes by passing an attributes hash to $options. For
     * attributes with no value (like disabled and readonly), give it a value
     * of TRUE in the $options array.
     *
     * <code>
     * $this->tag('br')
     * // => <br>
     * $this->tag('input', array('type' => 'text', 'disabled' => true))
     * // => <input type="text" disabled="disabled">
     * </code>
     *
     * @param string $name     Tag name.
     * @param string $options  Tag attributes.
     *
     * @return string  Generated HTML tag.
     */
    public function tag($name, $options = null)
    {
        return "<$name"
            . ($options ? $this->tagOptions($options) : '')
            . ' />';
    }

    /**
     * Returns an HTML block tag of type $name surrounding the $content.
     *
     * Add HTML attributes by passing an attributes hash to $options. For
     * attributes with no value (like disabled and readonly), give it a value
     * of TRUE in the $options array.
     *
     * <code>
     * $this->contentTag('p', 'Hello world!')
     * // => <p>Hello world!</p>
     * $this->contentTag('div',
     *                   $this->contentTag('p', 'Hello world!'),
     *                   array('class' => 'strong'))
     * // => <div class="strong"><p>Hello world!</p></div>
     * $this->contentTag('select', $options, array('multiple' => true))
     * // => <select multiple="multiple">...options...</select>
     * </code>
     *
     * @param string $name     Tag name.
     * @param string $content  Content to place between the tags.
     * @param array $options   Tag attributes.
     *
     * @return string  Generated HTML tags with content between.
     */
    public function contentTag($name, $content, $options = null)
    {
        $tagOptions = ($options ? $this->tagOptions($options) : '');
        return "<$name$tagOptions>$content</$name>";
    }

    /**
     * Returns a CDATA section with the given $content.
     *
     * CDATA sections are used to escape blocks of text containing characters
     * which would otherwise be recognized as markup. CDATA sections begin with
     * the string "<![CDATA[" and end with (and may not contain) the string
     * "]]>".
     *
     * <code>
     * $this->cdataSection('<hello world>');
     * // => <![CDATA[<hello world>]]>
     *
     * @param string $content  Content for inside CDATA section.
     *
     * @return string  CDATA section with content.
     */
    public function cdataSection($content)
    {
        return "<![CDATA[$content]]>";
    }

    /**
     * Escapes a value for output in a view template.
     *
     * <code>
     * <p><?php echo $this->escape($this->templateVar) ?></p>
     * </code>
     *
     * @param string $var  The output to escape.
     *
     * @return string  The escaped value.
     */
    public function escape($var)
    {
        return htmlspecialchars($var, ENT_QUOTES, $this->_view->getEncoding());
    }

    /**
     * Returns the escaped $html without affecting existing escaped entities.
     *
     * <code>
     * $this->escapeOnce('1 > 2 &amp; 3')
     * // => '1 &lt; 2 &amp; 3'
     *
     * @param string $html  HTML to be escaped.
     *
     * @return string  Escaped HTML without affecting existing escaped entities.
     */
    public function escapeOnce($html)
    {
        return $this->_fixDoubleEscape($this->escape($html));
    }

    /**
     * Converts an associative array of $options into a string of HTML
     * attributes.
     *
     * @param array $options  Key/value pairs.
     *
     * @return string  'key1="value1" key2="value2"'
     */
    public function tagOptions($options)
    {
        foreach ($options as $k => $v) {
            if ($v === null || $v === false) {
                unset($options[$k]);
            }
        }

        if (!empty($options)) {
            foreach ($options as $k => &$v) {
                if (in_array($k, $this->_booleanAttributes)) {
                    $v = $k;
                } else {
                    $v = $k . '="' . $this->escapeOnce($v) . '"';
                }
            }
            sort($options);
            return ' ' . implode(' ', $options);
        } else {
            return '';
        }
    }

    /**
     * Fix double-escaped entities, such as &amp;amp;, &amp;#123;, etc.
     *
     * @param string $escaped  Double-escaped entities.
     *
     * @return string  Entities fixed.
     */
    private function _fixDoubleEscape($escaped)
    {
        return preg_replace('/&amp;([a-z]+|(#\d+));/i', '&\\1;', $escaped);
    }
}