Ignore leading/trailing whitespace in config files

git-svn-id: https://svn.perl.org/qpsmtpd/trunk@966 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Henry Baragar 2009-01-02 20:41:00 +00:00 committed by Ask Bjørn Hansen
parent 79c5a726a3
commit 4bbdd551b4
4 changed files with 13 additions and 3 deletions

View File

@ -62,6 +62,8 @@
New config option "spool_perms" to set permissions of spool_dir
(Jared Johnson)
leading/trailing whitespace in config files is ignored (Henry Baragar)
0.43 - February 5, 2008
(This release was mostly done by Matt Sergeant and Hanno Hecker)

View File

@ -1,4 +1,5 @@
# Format is IP, or IP part with trailing dot
# e.g. "127.0.0.1", or "192.168."
127.0.0.1
192.168.
# leading/trailing whitespace is ignored
192.168.

View File

@ -239,7 +239,9 @@ sub _config_from_file {
open CF, "<$configfile" or warn "$$ could not open configfile $configfile: $!" and return;
my @config = <CF>;
chomp @config;
@config = grep { length($_) and $_ !~ m/^\s*#/ and $_ =~ m/\S/} @config;
@config = grep { length($_) and $_ !~ m/^\s*#/ and $_ =~ m/\S/}
map {s/^\s+//; s/\s+$//; $_;} # trim leading/trailing whitespace
@config;
close CF;
my $pos = 0;

View File

@ -17,6 +17,11 @@ ok(my ($smtpd, $conn) = Test::Qpsmtpd->new_conn(), "get new connection");
is($smtpd->config('me'), 'some.host.example.org', 'config("me")');
# test for ignoring leading/trailing whitespace (relayclients has a
# line with both)
my $relayclients = join ",", sort $smtpd->config('relayclients');
is($relayclients, '127.0.0.1,192.168.', 'config("relayclients") are trimmed');
unlink "./config.sample/me";