This file is indexed.

/usr/share/chromium/extensions/ublock-origin/lib/publicsuffixlist.js is in chromium-ublock-origin 1.13.8+dfsg-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
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
357
358
359
360
361
362
363
364
365
366
367
/*******************************************************************************

    publicsuffixlist.js - an efficient javascript implementation to deal with
    Mozilla Foundation's Public Suffix List <http://publicsuffix.org/list/>
    Copyright (C) 2013  Raymond Hill

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see {http://www.gnu.org/licenses/}.

*/

/*! Home: https://github.com/gorhill/publicsuffixlist.js */

/*
    This code is mostly dumb: I consider this to be lower-level code, thus
    in order to ensure efficiency, the caller is responsible for sanitizing
    the inputs.
*/

/******************************************************************************/

// A single instance of PublicSuffixList is enough.

;(function(root) {

'use strict';

/******************************************************************************/

var exceptions = {};
var rules = {};
var selfieMagic = 'iscjsfsaolnm';

// This value dictate how the search will be performed:
//    < this.cutoffLength = indexOf()
//   >= this.cutoffLength = binary search
var cutoffLength = 256;
var mustPunycode = /[^a-z0-9.-]/;

var onChangedListeners = [];

/******************************************************************************/

// In the context of this code, a domain is defined as:
//   "{label}.{public suffix}".
// A single standalone label is a public suffix as per
// http://publicsuffix.org/list/:
//   "If no rules match, the prevailing rule is '*' "
// This means 'localhost' is not deemed a domain by this
// code, since according to the definition above, it would be
// evaluated as a public suffix. The caller is therefore responsible to
// decide how to further interpret such public suffix.
//
// `hostname` must be a valid ascii-based hostname.

function getDomain(hostname) {
    // A hostname starting with a dot is not a valid hostname.
    if ( !hostname || hostname.charAt(0) === '.' ) {
        return '';
    }
    hostname = hostname.toLowerCase();
    var suffix = getPublicSuffix(hostname);
    if ( suffix === hostname ) {
        return '';
    }
    var pos = hostname.lastIndexOf('.', hostname.lastIndexOf('.', hostname.length - suffix.length) - 1);
    if ( pos <= 0 ) {
        return hostname;
    }
    return hostname.slice(pos + 1);
}

/******************************************************************************/

// Return longest public suffix.
//
// `hostname` must be a valid ascii-based string which respect hostname naming.

function getPublicSuffix(hostname) {
    if ( !hostname ) {
        return '';
    }
    // Since we slice down the hostname with each pass, the first match
    // is the longest, so no need to find all the matching rules.
    var pos;
    while ( true ) {
        pos = hostname.indexOf('.');
        if ( pos < 0 ) {
            return hostname;
        }
        if ( search(exceptions, hostname) ) {
            return hostname.slice(pos + 1);
        }
        if ( search(rules, hostname) ) {
            return hostname;
        }
        if ( search(rules, '*' + hostname.slice(pos)) ) {
            return hostname;
        }
        hostname = hostname.slice(pos + 1);
    }
    // unreachable
}

/******************************************************************************/

// Look up a specific hostname.

function search(store, hostname) {
    // Extract TLD
    var pos = hostname.lastIndexOf('.');
    var tld, remainder;
    if ( pos < 0 ) {
        tld = hostname;
        remainder = hostname;
    } else {
        tld = hostname.slice(pos + 1);
        remainder = hostname.slice(0, pos);
    }
    var substore = store[tld];
    if ( !substore ) {
        return false;
    }
    // If substore is a string, use indexOf()
    if ( typeof substore === 'string' ) {
        return substore.indexOf(' ' + remainder + ' ') >= 0;
    }
    // It is an array: use binary search.
    var l = remainder.length;
    var haystack = substore[l];
    if ( !haystack ) {
        return false;
    }
    var left = 0;
    var right = Math.floor(haystack.length / l + 0.5);
    var i, needle;
    while ( left < right ) {
        i = left + right >> 1;
        needle = haystack.substr( l * i, l );
        if ( remainder < needle ) {
            right = i;
        } else if ( remainder > needle ) {
            left = i + 1;
        } else {
            return true;
        }
    }
    return false;
}

/******************************************************************************/

// Parse and set a UTF-8 text-based suffix list. Format is same as found at:
// http://publicsuffix.org/list/
//
// `toAscii` is a converter from unicode to punycode. Required since the
// Public Suffix List contains unicode characters.
// Suggestion: use <https://github.com/bestiejs/punycode.js> it's quite good.

function parse(text, toAscii) {
    exceptions = {};
    rules = {};

    // http://publicsuffix.org/list/:
    // "... all rules must be canonicalized in the normal way
    // for hostnames - lower-case, Punycode ..."
    text = text.toLowerCase();

    var lineBeg = 0, lineEnd;
    var textEnd = text.length;
    var line, store, pos, tld;

    while ( lineBeg < textEnd ) {
        lineEnd = text.indexOf('\n', lineBeg);
        if ( lineEnd < 0 ) {
            lineEnd = text.indexOf('\r', lineBeg);
            if ( lineEnd < 0 ) {
                lineEnd = textEnd;
            }
        }
        line = text.slice(lineBeg, lineEnd).trim();
        lineBeg = lineEnd + 1;

        if ( line.length === 0 ) {
            continue;
        }

        // Ignore comments
        pos = line.indexOf('//');
        if ( pos >= 0 ) {
            line = line.slice(0, pos);
        }

        // Ignore surrounding whitespaces
        line = line.trim();
        if ( !line ) {
            continue;
        }

        if ( mustPunycode.test(line) ) {
            line = toAscii(line);
        }

        // Is this an exception rule?
        if ( line.charAt(0) === '!' ) {
            store = exceptions;
            line = line.slice(1);
        } else {
            store = rules;
        }

        // Extract TLD
        pos = line.lastIndexOf('.');
        if ( pos < 0 ) {
            tld = line;
        } else {
            tld = line.slice(pos + 1);
            line = line.slice(0, pos);
        }

        // Store suffix using tld as key
        if ( !store.hasOwnProperty(tld) ) {
            store[tld] = [];
        }
        if ( line ) {
            store[tld].push(line);
        }
    }
    crystallize(exceptions);
    crystallize(rules);
    callListeners(onChangedListeners);
}

/******************************************************************************/

// Cristallize the storage of suffixes using optimal internal representation
// for future look up.

function crystallize(store) {
    var suffixes, suffix, i, l;

    for ( var tld in store ) {
        if ( !store.hasOwnProperty(tld) ) {
            continue;
        }
        suffixes = store[tld].join(' ');
        // No suffix
        if ( !suffixes ) {
            store[tld] = '';
            continue;
        }
        // Concatenated list of suffixes less than cutoff length:
        //   Store as string, lookup using indexOf()
        if ( suffixes.length < cutoffLength ) {
            store[tld] = ' ' + suffixes + ' ';
            continue;
        }
        // Concatenated list of suffixes greater or equal to cutoff length
        //   Store as array keyed on suffix length, lookup using binary search.
        // I borrowed the idea to key on string length here:
        //   http://ejohn.org/blog/dictionary-lookups-in-javascript/#comment-392072

        i = store[tld].length;
        suffixes = [];
        while ( i-- ) {
            suffix = store[tld][i];
            l = suffix.length;
            if ( !suffixes[l] ) {
                suffixes[l] = [];
            }
            suffixes[l].push(suffix);
        }
        l = suffixes.length;
        while ( l-- ) {
            if ( suffixes[l] ) {
                suffixes[l] = suffixes[l].sort().join('');
            }
        }
        store[tld] = suffixes;
    }
    return store;
}

/******************************************************************************/

function toSelfie() {
    return {
        magic: selfieMagic,
        rules: rules,
        exceptions: exceptions
    };
}

function fromSelfie(selfie) {
    if ( typeof selfie !== 'object' || typeof selfie.magic !== 'string' || selfie.magic !== selfieMagic ) {
        return false;
    }
    rules = selfie.rules;
    exceptions = selfie.exceptions;
    callListeners(onChangedListeners);
    return true;
}

/******************************************************************************/

var addListener = function(listeners, callback) {
    if ( typeof callback !== 'function' ) {
        return;
    }
    if ( listeners.indexOf(callback) === -1 ) {
        listeners.push(callback);
    }
};

var removeListener = function(listeners, callback) {
    var pos = listeners.indexOf(callback);
    if ( pos !== -1 ) {
        listeners.splice(pos, 1);
    }
};

var callListeners = function(listeners) {
    for ( var i = 0; i < listeners.length; i++ ) {
        listeners[i]();
    }
};

/******************************************************************************/

var onChanged = {
    addListener: function(callback) {
        addListener(onChangedListeners, callback);
    },
    removeListener: function(callback) {
        removeListener(onChangedListeners, callback);
    }
};

/******************************************************************************/

// Public API

root = root || window;

root.publicSuffixList = {
    'version': '1.0',
    'parse': parse,
    'getDomain': getDomain,
    'getPublicSuffix': getPublicSuffix,
    'toSelfie': toSelfie,
    'fromSelfie': fromSelfie,
    'onChanged': onChanged
};

/******************************************************************************/

})(this);