diff options
author | Niels Thykier <niels@thykier.net> | 2022-12-14 20:48:15 +0000 |
---|---|---|
committer | Niels Thykier <niels@thykier.net> | 2022-12-14 20:56:38 +0000 |
commit | 1c4a66881eec1fe86b275d9a8454ef60b27b9622 (patch) | |
tree | c420f65478f0c381da194f2e232017f9e94be401 | |
parent | 7a6d9e58a4903fb898b63a0171f415bea395822b (diff) |
Dh_Lib.pm: Have addsubstvars check the value for newlines
Closes: #1026014
Signed-off-by: Niels Thykier <niels@thykier.net>
-rw-r--r-- | lib/Debian/Debhelper/Dh_Lib.pm | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Debian/Debhelper/Dh_Lib.pm b/lib/Debian/Debhelper/Dh_Lib.pm index afd183ea..63cd1476 100644 --- a/lib/Debian/Debhelper/Dh_Lib.pm +++ b/lib/Debian/Debhelper/Dh_Lib.pm @@ -1442,6 +1442,19 @@ sub addsubstvar { my $substvarfile = "debian/${ext}substvars"; my $str = $deppackage; $str .= " ($verinfo)" if defined $verinfo && length $verinfo; + + if (not defined($deppackage) and not $remove) { + error("Bug in helper: Must provide a value for addsubstvar (or set the remove flag, but then use delsubstvar instead)") + } + + if (defined($str) and $str =~ m/[\n]/) { + $str =~ s/\n/\\n/g; + # Per #1026014 + warning('Unescaped newlines in the value of a substvars can cause broken substvars files (see #1025714).'); + warning("Hint: If you really need a newline character, provide it as \"\${Newline}\"."); + error("Bug in helper: The substvar must not contain a raw newline character (${substvar}=${str})"); + } + my $update_logic = sub { my ($line) = @_; return $line if $line !~ m/^\Q${substvar}\E([?]?=)(.*)/; |