diff options
author | Niels Thykier <niels@thykier.net> | 2019-08-17 12:43:11 +0000 |
---|---|---|
committer | Niels Thykier <niels@thykier.net> | 2019-08-17 12:43:11 +0000 |
commit | e6516b5f5b05106c4d34fc2eae6a185c01295864 (patch) | |
tree | 0db1cf386777f08ef0655a59b624973c07dd43ed /dh_installdeb | |
parent | 14d3765687545804842f48cb7d0268065da40b69 (diff) | |
download | debhelper-e6516b5f5b05106c4d34fc2eae6a185c01295864.tar.gz |
dh_installdeb: Detect invalid token names passed to -D in most cases
Signed-off-by: Niels Thykier <niels@thykier.net>
Diffstat (limited to 'dh_installdeb')
-rwxr-xr-x | dh_installdeb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/dh_installdeb b/dh_installdeb index 9f5f24c6..d15fb0e3 100755 --- a/dh_installdeb +++ b/dh_installdeb @@ -104,7 +104,7 @@ error in compat 12. Define tokens to be replaced inside the maintainer scripts when it is generated. Please note that the limitations described in L</Limitations in token names> also applies to tokens defined -on the command line. +on the command line. Invalid token names will trigger an error. In the simple case, this parameter will cause B<< #I<TOKEN># >> to be replaced by I<VALUE>. If I<VALUE> starts with a literal @@ -202,7 +202,9 @@ the concrete script. All tokens intended to be substituted must match the regex: #[A-Za-z0-9_.+]+# -Tokens that do not match that regex will be silently ignored. +Tokens that do not match that regex will be silently ignored if found in the +script template. Invalid token names passed to B<-D> or B<--define> will +cause B<dh_installdeb> to reject the command with an error in most cases. =cut @@ -393,6 +395,10 @@ sub per_package_subst { my %vars = %{$provided_subst}; $vars{'PACKAGE'} = $package if not exists($vars{'PACKAGE'}); for my $var (keys(%{$provided_subst})) { + if ($var !~ $Debian::Debhelper::Dh_Lib::MAINTSCRIPT_TOKEN_REGEX) { + warning("User defined token ${var} does not match ${Debian::Debhelper::Dh_Lib::MAINTSCRIPT_TOKEN_REGEX}"); + error("Invalid provided token ${var}: It cannot be substituted as it does not follow the token name rules"); + } if ($var =~ m/^pkg[.]\Q${package}\E[.](.+)$/) { my $new_key = $1; $vars{$new_key} = $provided_subst->{$var}; |