This file is indexed.

/usr/lib/grass72/tools/html.py is in grass-dev 7.2.0-2.

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
from __future__ import (absolute_import, division, generators, nested_scopes,
                        print_function, unicode_literals, with_statement)
import sys
import HTMLParser as base
import htmlentitydefs

HTMLParseError = base.HTMLParseError

__all__ = ["HTMLParser", "HTMLParseError"]

omit_start = ["body", "tbody", "head", "html"]

single = ["area", "base", "basefont", "br", "col", "frame",
          "hr", "img", "input", "isindex", "link", "meta", "param"]
single = frozenset(single)

heading = ["h1", "h2", "h3", "h4", "h5", "h6"]
fontstyle = ["tt", "i", "b", "u", "s", "strike", "big", "small"]
phrase = ["em", "strong", "dfn", "code", "samp", "kbd", "var", "cite", "abbr",
          "acronym"]
special = ["a", "img", "applet", "object", "font", "basefont", "br", "script",
           "map", "q", "sub", "sup", "span", "bdo", "iframe"]
formctrl = ["input", "select", "textarea", "label", "button"]
lists = ["ul", "ol", " dir", "menu"]
head_misc = ["script", "style", "meta", "link", "object"]
pre_exclusion = ["img", "object", "applet", "big", "small", "sub", "sup",
                 "font", "basefont"]
block = ["p", "pre", "dl", "div", "center", "noscript", "noframes",
         "blockquote", "form", "isindex", "hr", "table", "fieldset",
         "address"] + heading + lists
inline = fontstyle + phrase + special + formctrl
flow = block + inline
html_content = ["head", "body"]
head_content = ["title", "isindex", "base"]


def setify(d):
    return dict([(key, frozenset(val)) for key, val in d.iteritems()])


def omit(allowed, tags):
    result = {}
    for k, v in allowed.iteritems():
        for t in tags:
            if t in v:
                v = v.union(allowed[t])
        result[k] = v
    return result

allowed = {
    "a": inline,
    "abbr": inline,
    "acronym": inline,
    "address": inline + ["p"],
    "applet": flow + ["param"],
    "b": inline,
    "bdo": inline,
    "big": inline,
    "blockquote": flow,
    "body": flow + ["ins", "del"],
    "button": flow,
    "caption": inline,
    "center": flow,
    "cite": inline,
    "code": inline,
    "colgroup": ["col"],
    "dd": flow,
    "del": flow,
    "dfn": inline,
    "dir": ["li"],
    "div": flow,
    "dl": ["dt", "dd"],
    "dt": inline,
    "em": inline,
    "fieldset": flow + ["legend"],
    "font": inline,
    "form": flow,
    "frameset": ["frameset", "frame", "noframes"],
    "h1": inline,
    "h2": inline,
    "h3": inline,
    "h4": inline,
    "h5": inline,
    "h6": inline,
    "head": head_content + head_misc,
    "html": html_content,
    "i": inline,
    "iframe": flow,
    "ins": flow,
    "kbd": inline,
    "label": inline,
    "legend": inline,
    "li": flow,
    "map": block + ["area"],
    "menu": ["li"],
    "noframes": flow,
    "noscript": flow,
    "object": flow + ["param"],
    "ol": ["li"],
    "optgroup": ["option"],
    "option": [],
    "p": inline,
    "pre": inline,
    "q": inline,
    "s": inline,
    "samp": inline,
    "script": [],
    "select": ["optgroup", "option"],
    "small": inline,
    "span": inline,
    "strike": inline,
    "strong": inline,
    "style": [],
    "sub": inline,
    "sup": inline,
    "table": ["caption", "col", "colgroup", "thead", "tfoot", "tbody"],
    "tbody": ["tr"],
    "td": flow,
    "textarea": [],
    "tfoot": ["tr"],
    "th": flow,
    "thead": ["tr"],
    "title": [],
    "tr": ["th", "td"],
    "tt": inline,
    "u": inline,
    "ul": ["li"],
    "var": inline
}

allowed = setify(allowed)
allowed = omit(allowed, omit_start)

excluded = {
    "a": ["a"],
    "button": formctrl + ["a", "form", "isindex", "fieldset", "iframe"],
    "dir": block,
    "form": ["form"],
    "label": ["label"],
    "menu": block,
    "pre": pre_exclusion
}

excluded = setify(excluded)


class HTMLParser(base.HTMLParser):

    def __init__(self, entities=None):
        base.HTMLParser.__init__(self)
        self.tag_stack = []
        self.excluded = frozenset()
        self.excluded_stack = []
        self.data = []
        self.data_stack = []
        self.decls = []
        if entities:
            self.entities = entities
        else:
            self.entities = {}

    def top(self):
        if self.tag_stack == []:
            return None
        else:
            return self.tag_stack[-1][0]

    def pop(self):
        self.excluded = self.excluded_stack.pop()
        data = self.data
        self.data = self.data_stack.pop()
        (tag, attrs) = self.tag_stack.pop()
        self.append((tag, attrs, data))
        return tag

    def push(self, tag, attrs):
        self.tag_stack.append((tag, attrs))
        self.excluded_stack.append(self.excluded)
        if tag in excluded:
            self.excluded = self.excluded.union(excluded[tag])
        self.data_stack.append(self.data)
        self.data = []

    def append(self, item):
        self.data.append(item)

    def is_allowed(self, tag):
        return tag not in self.excluded and tag in allowed[self.top()]

    def handle_starttag(self, tag, attrs):
        if self.tag_stack != []:
            while not self.is_allowed(tag):
                self.pop()
        if tag not in single:
            self.push(tag, attrs)
        else:
            self.append((tag, attrs, None))

    def handle_entityref(self, name):
        if name in self.entities:
            self.handle_data(self.entities[name])
        elif name in htmlentitydefs.entitydefs:
            self.handle_data(htmlentitydefs.entitydefs[name])
        else:
            sys.stderr.write("unrecognized entity: %s\n" % name)

    def handle_charref(self, name):
        sys.stderr.write('unsupported character reference <%s>' % name)

    def handle_data(self, data):
        self.append(data)

    def handle_endtag(self, tag):
        while True:
            if self.pop() == tag:
                break

    def handle_decl(self, decl):
        self.decls.append(decl)