summaryrefslogtreecommitdiffstats
path: root/lib/MDK
diff options
context:
space:
mode:
authorPascal Terjan <pterjan@mandriva.org>2009-03-10 17:19:35 +0000
committerPascal Terjan <pterjan@mandriva.org>2009-03-10 17:19:35 +0000
commitd1aaeb46ed5fc7609199c491627abdc16970d0b2 (patch)
treebdd4da9a93947e458e68d16171f2eb6ecad03c9f /lib/MDK
parent3c47af81cc0fcd39a403feccb72e281ea87f1f24 (diff)
downloadperl-MDK-Common-d1aaeb46ed5fc7609199c491627abdc16970d0b2.tar
perl-MDK-Common-d1aaeb46ed5fc7609199c491627abdc16970d0b2.tar.gz
perl-MDK-Common-d1aaeb46ed5fc7609199c491627abdc16970d0b2.tar.bz2
perl-MDK-Common-d1aaeb46ed5fc7609199c491627abdc16970d0b2.tar.xz
perl-MDK-Common-d1aaeb46ed5fc7609199c491627abdc16970d0b2.zip
protect various chars in setExportedVarsInSh and setExportedVarsInCsh
Diffstat (limited to 'lib/MDK')
-rw-r--r--lib/MDK/Common.pm.pl2
-rw-r--r--lib/MDK/Common/System.pm26
2 files changed, 15 insertions, 13 deletions
diff --git a/lib/MDK/Common.pm.pl b/lib/MDK/Common.pm.pl
index 3ca2d6f..5f53635 100644
--- a/lib/MDK/Common.pm.pl
+++ b/lib/MDK/Common.pm.pl
@@ -73,7 +73,7 @@ our @ISA = qw(Exporter);
# perl_checker: RE-EXPORT-ALL
our @EXPORT = map { @$_ } map { values %{'MDK::Common::' . $_ . 'EXPORT_TAGS'} } grep { /::$/ } keys %MDK::Common::;
-our $VERSION = "1.2.16";
+our $VERSION = "1.2.17";
1;
EOF
diff --git a/lib/MDK/Common/System.pm b/lib/MDK/Common/System.pm
index e3d514d..419a8d4 100644
--- a/lib/MDK/Common/System.pm
+++ b/lib/MDK/Common/System.pm
@@ -368,20 +368,22 @@ sub setVarsInSh {
setVarsInShMode($file, 0777 ^ umask(), $l, @fields);
}
+sub quoteForSh {
+ my ($val) = @_;
+ if ($val =~ /["`\$]/) {
+ $val =~ s/(')/\\$1/g;
+ $val = qq('$val');
+ } elsif ($val =~ /[\(\)'|\s\\;<>&#\[\]~{}*?]/) {
+ $val = qq("$val");
+ }
+ $val;
+}
+
sub setVarsInShMode {
my ($file, $mod, $l, @fields) = @_;
@fields = keys %$l unless @fields;
my $string = join('',
- map {
- my $val = $l->{$_};
- if ($val =~ /["`\$]/) {
- $val =~ s/(')/\\$1/g;
- $val = qq('$val');
- } elsif ($val =~ /[\(\)'|\s\\;<>&#\[\]~{}*?]/) {
- $val = qq("$val");
- }
- "$_=$val\n";
- } grep { $l->{$_} } @fields
+ map { "$_=".quoteForSh($l->{$_})."\n" } grep { $l->{$_} } @fields
);
if ($file =~ m!^/home/!) {
MDK::Common::File::secured_output($file, $string);
@@ -397,7 +399,7 @@ sub setExportedVarsInSh {
@fields = keys %$l unless @fields;
MDK::Common::File::output($file,
- (map { $l->{$_} ? "$_=$l->{$_}\n" : () } @fields),
+ (map { $l->{$_} ? "$_=".quoteForSh($l->{$_})."\n" : () } @fields),
@fields ? "export " . join(" ", @fields) . "\n" : (),
);
}
@@ -406,7 +408,7 @@ sub setExportedVarsInCsh {
my ($file, $l, @fields) = @_;
@fields = keys %$l unless @fields;
- MDK::Common::File::output($file, map { $l->{$_} ? "setenv $_ $l->{$_}\n" : () } @fields);
+ MDK::Common::File::output($file, map { $l->{$_} ? "setenv $_ ".quoteForSh($l->{$_})."\n" : () } @fields);
}
sub template2file {