Subject: | Config parser broken for string attributes that contain a right curly bracket. |
The config parser cannot handle string attributes that can contain an
arbitrary string of characters, including a right curly bracket [}].
The parser incorrectly assumes that this is the end of the block
definition and the remaining attributes for that definition are left
unassigned.
I created a very simple patch for this bug that will probably work in
most cases, but it assumes that the right curly bracket that closes a
definition block contains no more important data or comments after it on
the same line and is only followed by zero or more white spaces. This
was just the simplest solution that worked for our Nagios config, but a
proper fix may require a more complicated parser rewrite to be context
sensitive and allow right curly brackets within string attributes.
~Jason
Subject: | perl-Nagios-Object-Config-broken_string_attributes.patch |
diff -uNr Nagios-Object-0.21.3-dist/lib/Nagios/Object/Config.pm Nagios-Object-0.21.3/lib/Nagios/Object/Config.pm
--- Nagios-Object-0.21.3-dist/lib/Nagios/Object/Config.pm 2009-02-20 11:30:34.000000000 -0500
+++ Nagios-Object-0.21.3/lib/Nagios/Object/Config.pm 2009-05-28 16:06:49.000000000 -0400
@@ -181,7 +181,12 @@
}
# end of object definition
- if ( $line =~ /}(.*)$/ ) {
+ # Some object attributes are strings, which can contain a right-curly bracket and confuse this parser:
+ # - The proper fix would be to make the parser sensitive to arbitrary string attributes, but I will just
+ # do it the easy way for now and assume there is no more text on the same line after the right-curly
+ # bracket that closes the object definition.
+ #if ( $line =~ /}(.*)$/ ) {
+ if ( $line =~ /}(\s*)$/ ) {
$in_definition = undef;
# continue parsing after closing object with text following the '}'
$append = $1;