This file is indexed.

/usr/share/php/Horde/Text/Filter/Linkurls.php is in php-horde-text-filter 2.2.0-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
<?php
/**
 * The Horde_Text_Filter_Linkurls:: class turns all URLs in the text into
 * hyperlinks. The regex used is adapted from John Gruber's:
 * http://daringfireball.net/2010/07/improved_regex_for_matching_urls
 *
 * Changes:
 *   - Require at least one slash after the protocol. Horde's other filters
 *     don't expect us to match mailto: as part of these filters, so don't.
 *   - Limit the URL protocol to 20 characters to avoid PCRE problems.
 *   - Allow "+" characters in URL protocols (like svn+ssh://).
 *
 * Parameters:
 *   - callback: (string) A callback function that the URL is passed through
 *               before being set as the href attribute.  Must be a string
 *               with the function name, the function must take the original
 *               URL as the first and only parameter.
 *               DEFAULT: No callback
 *   - class: (string) The CSS class of the generated links.
 *            DEFAULT: none
 *   - encode: (boolean)  Whether to escape special HTML characters in the
 *             URLs and finally "encode" the complete tag so that it can be
 *             decoded later with the decode() method. This is useful if you
 *             want to run htmlspecialchars() or similar *after* using this
 *             filter.
 *             DEFAULT: false
 *   - nofollow: (boolean) Whether to set the 'rel="nofollow"' attribute on
 *               links.
 *               DEFAULT: false
 *   - target: (string) The link target.
 *             DEFAULT: '_blank'
 *
 * Copyright 2003-2013 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 *
 * @author   Tyler Colbert <tyler@colberts.us>
 * @author   Jan Schneider <jan@horde.org>
 * @author   Chuck Hagenbuch <chuck@horde.org>
 * @category Horde
 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 * @package  Text_Filter
 */
class Horde_Text_Filter_Linkurls extends Horde_Text_Filter_Base
{
    /**
     * Link-finding regex
     */
    public static $regex = '';

    /**
     * Filter parameters.
     *
     * @var array
     */
    protected $_params = array(
        'callback' => null,
        'class' => '',
        'encode' => false,
        'nofollow' => false,
        'target' => '_blank',
    );

    /**
     * Return the regex used to search for links.
     *
     * @return string  The regex string.
     */
    public static function getRegex()
    {
        if (!self::$regex) {
            self::initializeRegex();
        }

        return self::$regex;
    }

    /**
     * Initialize the regex for this instance.
     */
    public static function initializeRegex()
    {
        self::$regex = <<<END_OF_REGEX
(?xi)
(?:\b|^)
(  # Capture 1: entire matched URL
  (
   (?:[a-z][\w-+]{0,19})?:/{1,3}  # URL protocol and colon followed by 1-3
                                  # slashes, or just colon and slashes (://)
    |                             #  - or -
    (?<!\.)www\d{0,3}\.           # "www.", "www1.", "www2." … "www999."
                                  # without a leading period
    |                             #  - or -
    [a-z0-9.\-]+\.[a-z]{2,4}/    # looks like domain name followed by a slash
  )
  (?:                           # One or more:
    [^\s()<>\[\]]+                         # Run of non-space, non-()<>
    (?<![\s`!()\[\]{};:\'".,<>?«»“”‘’]{2}) # that is not followed by two or more
                                           # punct chars that indicate end-of-url
    |                                      #  - or -
    \(([^\s()<>]+|(\([^\s()<>]+\)))*\)     # balanced parens, up to 2 levels
  )+
  (?:                           # End with:
    \(([^\s()<>]+|(\([^\s()<>]+\)))*\)  # balanced parens, up to 2 levels
    |                                   #  - or -
    [^\s`!()\[\]{};:\'".,<>?«»“”‘’]     # not a space or one of these punct
                                        # chars
  )
)
END_OF_REGEX;
    }

    /**
     * Returns a hash with replace patterns.
     *
     * @return array  Patterns hash.
     */
    public function getPatterns()
    {
        return array(
            'regexp_callback' => array('@' . self::getRegex() . '@' => array($this, 'callback'))
        );
    }

    /**
     */
    public function callback($match)
    {
        $href = $match[0];
        if (strpos($match[2], ':') === false) {
            $href = 'http://' . $href;
        }

        if ($this->_params['callback']) {
            $href = call_user_func($this->_params['callback'], $href);
        }
        $href = htmlspecialchars($href);

        $class = $this->_params['class'];
        if (!empty($class)) {
            $class = ' class="' . $class . '"';
        }

        $target = $this->_params['target'];
        if (!empty($target)) {
            $target = ' target="' . $target . '"';
        }

        $replacement = '<a href="' . $href . '"' .
            ($this->_params['nofollow'] ? ' rel="nofollow"' : '') .
            $target . $class .
            '>' . htmlspecialchars($match[0]) . '</a>';

        if (!empty($this->_params['noprefetch'])) {
            $replacement = '<meta http-equiv="x-dns-prefetch-control" value="off" />' .
                $replacement .
                '<meta http-equiv="x-dns-prefetch-control" value="on" />';
        }

        if ($this->_params['encode']) {
            $replacement = chr(0) . chr(0) . chr(0) . base64_encode($replacement) . chr(0) . chr(0) . chr(0);
        }

        return $replacement;
    }

    /**
     * "Decodes" the text formerly encoded by using the "encode" parameter.
     *
     * @param string $text  An encoded text.
     *
     * @return string  The decoded text.
     */
    static public function decode($text)
    {
        return preg_replace_callback(
            '/\00\00\00([\w=+\/]*)\00\00\00/',
            function($hex) {
                return base64_decode($hex[1]);
            },
            $text);
    }

}