Author: robert Date: Fri Jan 2 12:41:00 2009 New Revision: 966 Modified: trunk/Changes trunk/config.sample/relayclients trunk/lib/Qpsmtpd.pm trunk/t/config.t
Log: Ignore leading/trailing whitespace in config files Author: Henry Baragar <[email protected]> Modified: trunk/Changes ============================================================================== --- trunk/Changes (original) +++ trunk/Changes Fri Jan 2 12:41:00 2009 @@ -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) Modified: trunk/config.sample/relayclients ============================================================================== --- trunk/config.sample/relayclients (original) +++ trunk/config.sample/relayclients Fri Jan 2 12:41:00 2009 @@ -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. +127.0.0.1 +# leading/trailing whitespace is ignored + 192.168. Modified: trunk/lib/Qpsmtpd.pm ============================================================================== --- trunk/lib/Qpsmtpd.pm (original) +++ trunk/lib/Qpsmtpd.pm Fri Jan 2 12:41:00 2009 @@ -239,7 +239,9 @@ 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; Modified: trunk/t/config.t ============================================================================== --- trunk/t/config.t (original) +++ trunk/t/config.t Fri Jan 2 12:41:00 2009 @@ -17,6 +17,11 @@ 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";
