Ensure that $directive_callback->() gets an unaltered image

- pass omitted lines to that function as well

Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Tom Eastep 2016-11-06 08:03:31 -08:00
parent 6a89fd1367
commit daa2440d9a
No known key found for this signature in database
GPG Key ID: 96E6B3F2423A4D10

View File

@ -564,6 +564,7 @@ our $usedcaller;
our $inline_matches; our $inline_matches;
our $currentline; # Current config file line image our $currentline; # Current config file line image
our $rawcurrentline; # Current config file line with no variable expansion
our $currentfile; # File handle reference our $currentfile; # File handle reference
our $currentfilename; # File NAME our $currentfilename; # File NAME
our $currentlinenumber; # Line number our $currentlinenumber; # Line number
@ -3736,6 +3737,7 @@ sub read_a_line($) {
if ( $omitting ) { if ( $omitting ) {
print "OMIT=> $_\n" if $debug; print "OMIT=> $_\n" if $debug;
$directive_callback->( 'OMITTED', $_ ) if ( $directive_callback );
next; next;
} }
@ -3790,6 +3792,10 @@ sub read_a_line($) {
# #
handle_first_entry if $first_entry; handle_first_entry if $first_entry;
# #
# Save Raw Image
#
$rawcurrentline = $currentline;
#
# Expand Shell Variables using %params and %actparams # Expand Shell Variables using %params and %actparams
# #
expand_variables( $currentline ) if $options & EXPAND_VARIABLES; expand_variables( $currentline ) if $options & EXPAND_VARIABLES;
@ -3818,7 +3824,7 @@ sub read_a_line($) {
fatal_error "Invalid SECTION name ($sectionname)" unless $sectionname =~ /^[-_\da-zA-Z]+$/; fatal_error "Invalid SECTION name ($sectionname)" unless $sectionname =~ /^[-_\da-zA-Z]+$/;
fatal_error "This file does not allow ?SECTION" unless $section_function; fatal_error "This file does not allow ?SECTION" unless $section_function;
$section_function->($sectionname); $section_function->($sectionname);
$directive_callback->( 'SECTION', $currentline ) if $directive_callback; $directive_callback->( 'SECTION', $rawcurrentline ) if $directive_callback;
next LINE; next LINE;
} else { } else {
fatal_error "Non-ASCII gunk in file" if ( $options && CHECK_GUNK ) && $currentline =~ /[^\s[:print:]]/; fatal_error "Non-ASCII gunk in file" if ( $options && CHECK_GUNK ) && $currentline =~ /[^\s[:print:]]/;