patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob 8edd816a20ceefa08ecc7f1bc2d1cfbe33fa8a89 1493 bytes (raw)
name: vm/app/systemd-sysupdate/escape-url.awk 	 # note: path name is non-authoritative(*)

 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
 
#!/usr/bin/awk -f
# SPDX-License-Identifier: EUPL-1.2+
# SPDX-FileCopyrightText: 2025 Demi Marie Obenour <demiobenour@gmail.com>
BEGIN {
    update_url = ARGV[1];
    # Check for a GNU awk misfeature
    newline = "\n";
    # Reject URLs with control characters, query parameters, or fragments.
    # They *cannot* work and so are rejected to produce better error messages.
    # curl rejects control characters with "Malformed input to a URL function".
    # Fragment specifiers ("#") and query parameters ("?") break concatenating
    # /SHA256SUMS and /SHA256SUMS.sha256.asc onto the update URL.  Also, it is
    # simpler to reject update URLs that contain whitespace than to try to
    # escape them.
    if (update_url ~ /^[^\001-\040?#\x7F]+$/) {
        # Backslashes are special to systemd-sysupdate.
        # Use \\\\& because without the & the result is
        # not portable between GNU awk and non-GNU awk.
        gsub(/\\/, "\\\\&", update_url);
        # "&" and "\\" are special on the RHS of a sed substitution
        # and must be escaped with another backslash.  The delimiter
        # ("#" in this case) and "\n" must also be escaped, but they
        # were rejected above so don't bother.
        gsub(/[&\\]/, "\\\\&", update_url);
        printf "%s", update_url;
        exit 0;
    } else {
        print "Bad update URL from host: control characters, whitespace, query parameters, and fragment specifiers not allowed" > "/dev/stderr";
        exit 100;
    }
}

debug log:

solving 8edd816a20ceefa08ecc7f1bc2d1cfbe33fa8a89 ...
found 8edd816a20ceefa08ecc7f1bc2d1cfbe33fa8a89 in https://inbox.spectrum-os.org/spectrum-devel/20251121-updates-v4-12-d4561c42776e@gmail.com/ ||
	https://inbox.spectrum-os.org/spectrum-devel/20251119-updates-v3-12-b88a99915509@gmail.com/

applying [1/1] https://inbox.spectrum-os.org/spectrum-devel/20251121-updates-v4-12-d4561c42776e@gmail.com/
diff --git a/vm/app/systemd-sysupdate/escape-url.awk b/vm/app/systemd-sysupdate/escape-url.awk
new file mode 100644
index 0000000000000000000000000000000000000000..8edd816a20ceefa08ecc7f1bc2d1cfbe33fa8a89

Checking patch vm/app/systemd-sysupdate/escape-url.awk...
Applied patch vm/app/systemd-sysupdate/escape-url.awk cleanly.

skipping https://inbox.spectrum-os.org/spectrum-devel/20251119-updates-v3-12-b88a99915509@gmail.com/ for 8edd816a20ceefa08ecc7f1bc2d1cfbe33fa8a89
index at:
100644 8edd816a20ceefa08ecc7f1bc2d1cfbe33fa8a89	vm/app/systemd-sysupdate/escape-url.awk

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).