Subject: | bugfix including empty config files for Apache::ConfigFile 1.18 |
Date: | Tue, 05 Jun 2007 16:43:02 +0200 |
To: | bug-Apache-Fake [...] rt.cpan.org |
From: | Michael Kefeder <michael.kefeder [...] world4you.com> |
Hi
I recently used this cpan module and found there's a bug for empty (as
in 0 bytes in size) config files included into another config file. for
example:
1. httpd.conf includes site1.conf, site2.conf and site3.conf
2. site1.conf is empty
3. BUG: site2.conf will not be included!
4. site3.conf will be included
The reason lies in the algorithm which parses and merges all included
configs into one array. On line 187 it uses splice to replace the
"Include line" if you will, an empty file will not replace that line, it
will delete it. Now the array is shorter - the next line index is off by
one. That's why it skips site2.conf and includes site3.conf next from my
example.
My bugfix is very simple, it adds a newline to _every_ config file
included. That doesn't do any harm to config files and makes empty
config files nonempty.
You can find the diff for Apache_ConfigFile.pm at the end of this email.
regards
Mike
--- Apache_ConfigFile.pm 2001-09-18 20:31:38.000000000 +0200
+++ Apache_ConfigFile.fixed.pm 2007-06-05 16:29:56.000000000 +0200
@@ -182,6 +182,7 @@
splice @conf, $i, 1, @f; # stick it inline
}
}
+ push (@conf, "\n"); # quick bugfix for empty config files
return @conf;
}