aboutsummaryrefslogtreecommitdiff
path: root/tests/guix-system.sh
blob: 9903677a0277dbca21462f711566be397c69cdd6 (about) (plain)
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
# GNU Guix --- Functional package management for GNU
# Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
# Copyright © 2018 Chris Marusich <cmmarusich@gmail.com>
#
# This file is part of GNU Guix.
#
# GNU Guix 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.
#
# GNU Guix 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 GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

#
# Test 'guix system', mostly error reporting.
#

set -e

guix system --version

tmpfile="t-guix-system-$$"
errorfile="t-guix-system-error-$$"

# Note: This directory is chosen outside $builddir so that relative file name
# canonicalization doesn't mess up with 'current-source-directory', used by
# 'local-file' ('load' forces 'relative' for
# %FILE-PORT-NAME-CANONICALIZATION.)
tmpdir="${TMPDIR:-/tmp}/t-guix-system-$$"
mkdir "$tmpdir"

trap 'rm -f "$tmpfile" "$errorfile" "$tmpdir"/*; rmdir "$tmpdir"' EXIT

# Reporting of syntax errors.

cat > "$tmpfile"<<EOF
;; This is line 1, and the next one is line 2.
   (operating-system)
;; The 'T' is at column 3.
EOF

if guix system vm "$tmpfile" 2> "$errorfile"
then
    # This must not succeed.
    exit 1
else
    grep "$tmpfile:2:3:.*missing.* initializers" "$errorfile"
fi


cat > "$tmpfile"<<EOF
;; This is line 1, and the next one is line 2.
   (operating-system
;; This is line 3, and there is no closing paren!
EOF

if guix system vm "$tmpfile" 2> "$errorfile"
then
    # This must not succeed.
    exit 1
else
    grep "$tmpfile:4:1: missing closing paren" "$errorfile"
fi


# Reporting of module not found errors.

cat > "$tmpfile" <<EOF
;; Line 1.
(use-modules (gnu))
  (use-service-modules openssh)
EOF

if guix system build "$tmpfile" -n 2> "$errorfile"
then false
else
    grep "$tmpfile:3:2: .*module .*openssh.*not found" "$errorfile"
    grep "Try.*use-service-modules ssh" "$errorfile"
fi

cat > "$tmpfile" <<EOF
;; Line 1.
(use-modules (gnu))
  (use-package-modules qemu)
EOF

if guix system build "$tmpfile" -n 2> "$errorfile"
then false
else
    grep "$tmpfile:3:2: .*module .*qemu.*not found" "$errorfile"
    grep "Try.*use-package-modules virtualization" "$errorfile"
fi

# Reporting of unbound variables.

cat > "$tmpfile" <<EOF
(use-modules (gnu))                                   ; 1
(use-service-modules networking)                      ; 2

(operating-system                                     ; 4
  (host-name "antelope")                              ; 5
  (timezone "Europe/Paris")                           ; 6
  (locale "en_US.UTF-8")                              ; 7

  (bootloader (GRUB-config (target "/dev/sdX")))      ; 9
  (file-systems (cons (file-system
                        (device (file-system-label "root"))
                        (mount-point "/")
                        (type "ext4"))
                      %base-file-systems)))
EOF

if guix system build "$tmpfile" -n 2> "$errorfile"
then false
else
    if test "`guile -c '(display (effective-version))'`" = 2.2
    then
	# FIXME: With Guile 2.2.0 the error is reported on line 4.
	# See <http://bugs.gnu.org/26107>.
	grep "$tmpfile:[49]:[0-9]\+:.*GRUB-config.*[Uu]nbound variable" "$errorfile"
    else
	grep "$tmpfile:9:[0-9]\+:.*GRUB-config.*[Uu]nbound variable" "$errorfile"
    fi
fi

OS_BASE='
  (host-name "antelope")
  (timezone "Europe/Paris")
  (locale "en_US.UTF-8")

  (bootloader (bootloader-configuration
               (bootloader grub-bootloader)
               (target "/dev/sdX")))
  (file-systems (cons (file-system
                        (device (file-system-label "root"))
                        (mount-point "/")
                        (type "ext4"))
                      %base-file-systems))
'

# Reporting of duplicate service identifiers.

cat > "$tmpfile" <<EOF
(use-modules (gnu))
(use-service-modules networking)

(operating-system
  $OS_BASE
  (services (cons* (service dhcp-client-service-type)
                   (service dhcp-client-service-type) ;twice!
                   %base-services)))
EOF

if guix system vm "$tmpfile" 2> "$errorfile"
then
    # This must not succeed.
    exit 1
else
    grep "service 'networking'.*more than once" "$errorfile"
fi

# Reporting unmet shepherd requirements.

cat > "$tmpfile" <<EOF
(use-modules (gnu) (gnu services shepherd))
(use-service-modules networking)

(define buggy-service-type
  (shepherd-service-type
    'buggy
    (lambda _
      (shepherd-service
        (provision '(buggy!))
        (requirement '(does-not-exist))
        (start #t)))))

(operating-system
  $OS_BASE
  (services (cons (service buggy-service-type #t)
                  %base-services)))
EOF

if guix system build "$tmpfile" 2> "$errorfile"
then
    exit 1
else
    grep "service 'buggy!'.*'does-not-exist'.*not provided" "$errorfile"
fi

# Reporting inconsistent user accounts.

make_user_config ()
{
    cat > "$tmpfile" <<EOF
(use-modules (gnu))
(use-service-modules networking)

(operating-system
  (host-name "antelope")
  (timezone "Europe/Paris")
  (locale "en_US.UTF-8")

  (bootloader (bootloader-configuration
                (bootloader grub-bootloader)
                (target "/dev/sdX")))
  (file-systems (cons (file-system
                        (device (file-system-label "root"))
                        (mount-point "/")
                        (type "ext4"))
                      %base-file-systems))
  (users (list (user-account
                 (name "dave")
                 (home-directory "/home/dave")
                 (group "$1")
                 (supplementary-groups '("$2"))))))
EOF
}

make_user_config "users" "wheel"
guix system build "$tmpfile" -n       # succeeds

guix system build "$tmpfile" -d	      # succeeds
guix system build "$tmpfile" -d | grep '\.drv$'

guix system vm "$tmpfile" -d	      # succeeds
guix system vm "$tmpfile" -d | grep '\.drv$'

# Make sure the behavior is deterministic (<https://bugs.gnu.org/32652>).
drv1="`guix system vm "$tmpfile" -d`"
drv2="`guix system vm "$tmpfile" -d`"
test "$drv1" = "$drv2"
drv1="`guix system disk-image --file-system-type=iso9660 "$tmpfile" -d`"
drv2="`guix system disk-image --file-system-type=iso9660 "$tmpfile" -d`"
test "$drv1" = "$drv2"

make_user_config "group-that-does-not-exist" "users"
if guix system build "$tmpfile" -n 2> "$errorfile"
then false
else grep "primary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi

make_user_config "users" "group-that-does-not-exist"
if guix system build "$tmpfile" -n 2> "$errorfile"
then false
else grep "supplementary group.*group-that-does-not-exist.*undeclared" "$errorfile"; fi

# Try 'local-file' and relative file name resolution.

cat > "$tmpdir/config.scm"<<EOF
(use-modules (gnu))
(use-service-modules networking)

(operating-system
  $OS_BASE
  (services (cons (service tor-service-type
                           (tor-configuration
                             (config-file (local-file "my-torrc"))))
                  %base-services)))
EOF

cat > "$tmpdir/my-torrc"<<EOF
# This is an example file.
EOF

# In both cases 'my-torrc' should be properly resolved.
guix system build "$tmpdir/config.scm" -n
(cd "$tmpdir"; guix system build "config.scm" -n)

# Searching.
guix system search tor | grep "^name: tor"
guix system search tor | grep "^shepherdnames: tor"
guix system search anonym network | grep "^name: tor"

# Below, use -n (--dry-run) for the tests because if we actually tried to
# build these images, the commands would take hours to run in the worst case.

# Verify that the examples can be built.
for example in gnu/system/examples/*; do
    guix system -n disk-image $example
done

# Verify that the disk image types can be built.
guix system -n vm gnu/system/examples/vm-image.tmpl
guix system -n vm-image gnu/system/examples/vm-image.tmpl
# This invocation was taken care of in the loop above:
# guix system -n disk-image gnu/system/examples/bare-bones.tmpl
guix system -n disk-image --file-system-type=iso9660 gnu/system/examples/bare-bones.tmpl
guix system -n docker-image gnu/system/examples/docker-image.tmpl
ass='add'>+function charset_from_BOM(data)
+{
+ for (const [BOM, charset] of BOMs) {
+ if (BOM.reduce((ac, byte, i) => ac && byte === data[i], true))
+ return charset;
+ }
+
+ return "";
+}
+
+const charset_attrs =
+ ['charset', 'http-equiv="content-type"', 'content*="charset"'];
+const charset_meta_selector =
+ charset_attrs.map(a => `head>meta[${a}]`).join(", ");
+
+function charset_from_meta_tags(doc)
+{
+ for (const meta of doc.querySelectorAll(charset_meta_selector)) {
+ const maybe_charset = meta.getAttribute("charset");
+ if (maybe_charset && validate_encoding(maybe_charset))
+ return maybe_charset;
+
+ const match = charset_reg.exec(meta.getAttribute("content"));
+ if (match && validate_encoding(match[1]))
+ return match[1];
+ }
+
+ return undefined;
+}
+
+function create_decoder(properties, data)
+{
+ let charset = charset_from_BOM(data) || properties.detected_charset;
+ if (!charset && data.indexOf(0) !== -1) {
+ console.debug("Warning: zeroes in bytestream, probable cached encoding mismatch. Trying to decode it as UTF-16.",
+ properties);
+ return new TextDecoder("utf-16be");
+ }
+
+ /* Missing HTTP charset, sniffing in content... */
+ /*
+ * TODO: I recall there is some standard saying how early in the doc the
+ * charset has to be specified. We could process just this part of data.
+ */
+ const text = new TextDecoder("latin1").decode(data, {stream: true});
+ properties.html = properties.html || /html/i.test(text);
+
+ if (properties.html) {
+ const tmp_doc = new DOMParser().parseFromString(text, "text/html");
+ charset = charset_from_meta_tags(tmp_doc);
+ }
+
+ return new TextDecoder(charset || "latin1");
+}
+
+function filter_data(properties, event)
+{
+ const data = new Uint8Array(event.data);
+ let first_chunk = false;
+ if (!properties.decoder) {
+ first_chunk = true;
+ properties.decoder = create_decoder(properties, data);
+ properties.encoder = new TextEncoder();
+ /* Force UTF-8, this is the only encoding we can produce. */
+ properties.filter.write(new Uint8Array(UTF8_BOM));
+ }
+
+ let decoded = properties.decoder.decode(data);
+
+ if (first_chunk) {
+ /*
+ * HAX! Our content scripts that execute at `document_start' will always
+ * run before the first script in the document, but under Mozilla some
+ * `<meta>' tags might already be loaded at that point. Here we inject a
+ * dummy `<script>' at the beginning (before any `<meta>' tags) that
+ * will force `document_start' to happen earlier. This way our content
+ * scripts will be able to sanitize `http-equiv' tags with CSP rules
+ * that would otherwise stop our injected scripts from executing.
+ */
+ const dummy_script =
+ `<script data-hachette-deleteme="${properties.policy.nonce}" nonce="${properties.policy.nonce}">null</script>`;
+ const doctype_decl = /^(\s*<!doctype[^<>"']*>)?/i.exec(decoded)[0];
+ decoded = doctype_decl + dummy_script +
+ decoded.substring(doctype_decl.length);
+ }
+
+ properties.filter.write(properties.encoder.encode(decoded));
+
+ if (properties.decoder.encoding === "utf-8")
+ properties.filter.disconnect();
+}
+
+function apply_stream_filter(details, headers, policy)
+{
+ if (policy.allow)
+ return headers;
+
+ const properties = properties_from_headers(headers);
+ properties.policy = policy;
+
+ properties.filter =
+ browser.webRequest.filterResponseData(details.requestId);
+
+ properties.filter.ondata = event => filter_data(properties, event);
+ properties.filter.onstop = () => properties.filter.close();
+
+ /*
+ * In the future we might consider modifying the headers that specify
+ * encoding. For now we are not yet doing it, though. However, we
+ * prepend the data with UTF-8 BOM which should be enough.
+ */
+ return headers;
+}
+
+/*
+ * EXPORTS_START
+ * EXPORT apply_stream_filter
+ * EXPORTS_END
+ */
diff --git a/content/main.js b/content/main.js
index 441636c..4ae7738 100644
--- a/content/main.js
+++ b/content/main.js
@@ -47,10 +47,7 @@ if (!is_privileged_url(document.URL)) {
handle_page_actions(policy.nonce);
- if (!policy.allow && is_mozilla)
- addEventListener('beforescriptexecute', mozilla_suppress_scripts, true);
-
- if (!policy.allow && is_chrome) {
+ if (!policy.allow) {
const old_html = document.documentElement;
const new_html = document.createElement("html");
old_html.replaceWith(new_html);
diff --git a/content/sanitize_document.js b/content/sanitize_document.js
index 1533526..727bb6c 100644
--- a/content/sanitize_document.js
+++ b/content/sanitize_document.js
@@ -43,76 +43,100 @@ function block_attribute(node, attr)
node.removeAttribute(attr);
}
-function sanitize_script(script, policy)
+function sanitize_script(script, data)
{
- if (policy.allow)
+ if (script.getAttribute("data-hachette-deleteme") === data.policy.nonce) {
+ script.remove();
+ script.hachette_deleted = true;
+ script.hachette_ignore = true;
+ }
+
+ if (data.policy.allow)
return;
block_attribute(script, "type");
script.setAttribute("type", "application/json");
}
-function inject_csp(head, policy)
+function inject_csp(head, data)
{
- if (policy.allow)
+ if (data.policy.allow)
return;
const meta = document.createElement("meta");
meta.setAttribute("http-equiv", "Content-Security-Policy");
- meta.setAttribute("content", csp_rule(policy.nonce));
+ meta.setAttribute("content", csp_rule(data.policy.nonce));
meta.hachette_ignore = true;
head.prepend(meta);
+
+ data.new_added.unshift([meta, head]);
}
-function sanitize_http_equiv_csp_rule(meta, policy)
+function sanitize_http_equiv_csp_rule(meta, data)
{
const http_equiv = meta.getAttribute("http-equiv");
+ const value = meta.content;
- if (!is_csp_header_name(http_equiv, !policy.allow))
+ if (!value || !is_csp_header_name(http_equiv, !data.policy.allow))
return;
- if (policy.allow || is_csp_header_name(http_equiv, false)) {
- let value = meta.getAttribute("content");
- block_attribute(meta, "content");
- if (value) {
- value = sanitize_csp_header({value}, policy).value;
- meta.setAttribute("content", value);
- }
- return;
- }
+ block_attribute(meta, "content");
- block_attribute(meta, "http-equiv");
+ if (data.policy.allow || is_csp_header_name(http_equiv, false))
+ meta.content = sanitize_csp_header({value}, data.policy).value;
}
-function sanitize_node(node, policy)
+function sanitize_node(node, data)
{
if (node.tagName === "SCRIPT")
- sanitize_script(node, policy);
+ sanitize_script(node, data);
if (node.tagName === "HEAD")
- inject_csp(node, policy);
+ inject_csp(node, data);
if (node.tagName === "META")
- sanitize_http_equiv_csp_rule(node, policy);
+ sanitize_http_equiv_csp_rule(node, data);
+
+ if (!data.policy.allow)
+ sanitize_attributes(node, data);
+}
- if (!policy.allow)
- sanitize_attributes(node, policy);
+/*
+ * Instead of calling writer directly with multiple small chunks of reconstruced
+ * HTML code, we utilize `setTimeout()' to only have it called once,
+ * asynchronously.
+ */
+function do_write_callback(data)
+{
+ data.writer(data.chunks.join(""));
+ data.chunks = [];
+
+ if (data.finished && data.finisher)
+ data.finisher();
+}
+
+function do_write(chunk, data)
+{
+ data.chunks.push(chunk);
+ clearTimeout(data.write_timeout);
+ data.write_timeout = setTimeout(() => do_write_callback(data), 0);
}
const serializer = new XMLSerializer();
-function start_node(node, data)
+function start_serializing_node(node, data)
{
+ node.hachette_started = true;
+
if (!data.writer)
return;
- node.hachette_started = true;
const clone = node.cloneNode(false);
clone.textContent = data.uniq;
- data.writer(data.uniq_reg.exec(clone.outerHTML)[1]);
+ do_write(data.uniq_reg.exec(clone.outerHTML)[1], data);
}
-function finish_node(node, data)
+function finish_serializing_node(node, data)
{
const nodes_to_process = [node];
@@ -127,40 +151,103 @@ function finish_node(node, data)
while (nodes_to_process.length > 0) {
const node = nodes_to_process.pop();
node.remove();
+ node.hachette_ignore = true;
if (!data.writer)
continue;
if (node.hachette_started) {
node.textContent = data.uniq;
- data.writer(data.uniq_reg.exec(node.outerHTML)[2]);
+ do_write(data.uniq_reg.exec(node.outerHTML)[2], data);
+ continue;
+ }
+
+ do_write(node.outerHTML || serializer.serializeToString(node), data);
+ }
+}
+
+function process_initial_nodes(node, data)
+{
+ if (data.processed_initial_nodes)
+ return;
+
+ data.processed_initial_nodes = true;
+
+ start_serializing_node(data.html_root, data);
+
+ const new_added = [];
+ const nodes_to_process = [data.html_root];
+
+ let i = 0;
+ while (nodes_to_process.length > 0) {
+ let current = nodes_to_process.shift();
+
+ if (current.firstChild) {
+ if (current.firstChild === node)
+ break;
+ nodes_to_process.unshift(current.firstChild, current);
+ new_added.push([current.firstChild, current]);
continue;
}
- data.writer(node.outerHTML || serializer.serializeToString(node));
+ while (current && !current.nextSibling)
+ current = nodes_to_process.shift();
+
+ if (!current || current.nextSibling === node)
+ break;
+
+ nodes_to_process.unshift(current.nextSibling);
+ new_added.push([current.nextSibling, nodes_to_process[1]]);
}
+
+ data.new_added.unshift(...new_added);
}
/*
* Important! Due to some weirdness node.parentElement is not alway correct
- * under Chromium. Track node relations manually.
+ * in MutationRecords under Chromium. Track node relations manually.
*/
function handle_added_node(node, true_parent, data)
{
- if (node.hachette_ignore || true_parent.hachette_ignore)
- return;
+ /*
+ * Functions we call here might cause new nodes to be injected or found
+ * that require processing before the one we got in function argument.
+ * We rely on those functions putting the node(s) they create/find at the
+ * very beginning of the `new_added' queue and (for created nodes) setting
+ * their `hachette_ignore' property, based on which their MutationRecord
+ * will not be processed. A function can also mark a node already in the
+ * `new_added' queue as not eligible for processing by setting its
+ * `hachette_deleted' property.
+ */
- if (!true_parent.hachette_started)
- start_node(true_parent, data)
+ process_initial_nodes(node, data);
- sanitize_node(node, data.policy);
+ data.new_added.push([node, true_parent]);
- if (data.node_eater)
- data.node_eater(node, true_parent);
+ while (data.new_added.length > 0) {
+ [node, true_parent] = data.new_added.shift();
- finish_node(true_parent.hachette_last_added, data);
+ if (true_parent.hachette_deleted)
+ node.hachette_deleted = true;
+ if (node.hachette_deleted)
+ continue;
+
+ if (!true_parent.hachette_started)
+ start_serializing_node(true_parent, data)
+
+ if (!node.hachette_ignore)
+ sanitize_node(node, data);
+
+ if (node.hachette_deleted)
+ continue;
+
+ if (data.node_eater)
+ data.node_eater(node, true_parent);
- true_parent.hachette_last_added = node;
+ finish_serializing_node(true_parent.hachette_last_added, data);
+
+ true_parent.hachette_last_added = node;
+ }
}
function handle_mutation(mutations, data)
@@ -170,28 +257,76 @@ function handle_mutation(mutations, data)
* node.parentElement. The former is the correct one.
*/
for (const mutation of mutations) {
- for (const node of mutation.addedNodes)
+ for (const node of mutation.addedNodes) {
+ /* Check for nodes added by ourselves. */
+ if (mutation.target.hachette_ignore)
+ node.hachette_ignore = true;
+ if (node.hachette_ignore)
+ continue;
+
handle_added_node(node, mutation.target, data);
+ }
}
}
function finish_processing(data)
{
+ process_initial_nodes(undefined, data);
+
+ /*
+ * The `finisher' callback should be called, if provided. Normally our
+ * function that performs the last write does it after seeing `finished'
+ * set to `true'. If, however, there's no `writer' callback and hence no
+ * writes to perform, we need to take care of calling `finisher' here.
+ */
+ data.finished = true;
handle_mutation(data.observer.takeRecords(), data);
- finish_node(data.html_element, data);
data.observer.disconnect();
+
+ /*
+ * Additional whitespace that was after `</body>' gets appended to body.
+ * Although it's a minor issue, it is not what we want. There's no way to
+ * tell exactly what part of that whitespace was after `</body>' and what
+ * was before, so we just replace it with a single newline which looks good
+ * when printed.
+ */
+ const body = data.html_root.lastChild;
+ const text = body && body.tagName === "BODY" && body.lastChild;
+ if (text && text.nodeName === "#text") {
+ const new_content = /^([\S\s]*\S)?\s*$/.exec(text.textContent)[1] || "";
+ text.textContent = new_content + "\n";
+ }
+
+ finish_serializing_node(data.html_root, data);
+ if (!data.writer && data.finisher)
+ setTimeout(data.finisher, 0);
}
-function modify_on_the_fly(html_element, policy, consumers)
+/*
+ * This function sanitizes `html_root' according to `policy'. It is capable of
+ * working on an HTML document that is being written to, sanitizing new nodes
+ * as they appear.
+ *
+ * `consumers' object may contain 3 optional callback functions: `writer',
+ * `node_eater' and `finisher'. The first one, if present, is called with chunks
+ * of reconstructed HTML code. The second one, if present, gets called for every
+ * added node with 2 arguments: that node and its parent. The third one is
+ * called at the end, after all processing has been done.
+ *
+ * `modify_on_the_fly()' returns a callback that should be called (with no
+ * arguments) once the document of html_root has finished being written to.
+ * Unfortunately, due to specifics behavior of document that has had its
+ * documentElement replaced
+ */
+function modify_on_the_fly(html_root, policy, consumers)
{
const uniq = gen_nonce();
- const uniq_reg = new RegExp(`^(.*)${uniq}(.*)$`);
- const data = {policy, html_element, uniq, uniq_reg, ...consumers};
-
- start_node(data.html_element, data);
+ const uniq_reg = new RegExp(`^([\\s\\S]*)${uniq}([\\s\\S]*)$`);
+ const data = {policy, html_root, uniq, uniq_reg, chunks: [], new_added: []};
+ Object.assign(data, consumers);
var observer = new MutationObserver(m => handle_mutation(m, data));
- observer.observe(data.html_element, {
+ observer.observe(data.html_root, {
attributes: true,
childList: true,
subtree: true
diff --git a/copyright b/copyright
index 05a16aa..40126fe 100644
--- a/copyright
+++ b/copyright
@@ -20,6 +20,13 @@ Copyright: 2021 Wojtek Kosior <koszko@koszko.org>
2021 jahoti <jahoti@tilde.team>
License: GPL-3+-javascript or Alicense-1.0
+Files: background/stream_filter.js
+Copyright: 2018 Giorgio Maone <giorgio@maone.net>
+ 2021 Wojtek Kosior <koszko@koszko.org>
+License: GPL-3+-javascript or Alicense-1.0, and GPL-3+
+Comment: Code by Wojtek is dual-licensed under GPL-3+-javascript and
+ Alicense-1.0. Giorgio's code is under GPL-3+.
+
Files: *.html README.txt copyright
Copyright: 2021 Wojtek Kosior <koszko@koszko.org>
License: GPL-3+ or Alicense-1.0 or CC-BY-SA-4.0