Support quoting config variables (#2175)
* allow handling of quotes in config files * copy paste error * surround zm_arptool in quotes
This commit is contained in:
parent
037abd4916
commit
3dc424282b
|
@ -50,4 +50,4 @@ ZM_PATH_SWAP=@ZM_TMPDIR@
|
||||||
|
|
||||||
# Full path to optional arp binary
|
# Full path to optional arp binary
|
||||||
# ZoneMinder will find the arp binary automatically on most systems
|
# ZoneMinder will find the arp binary automatically on most systems
|
||||||
ZM_PATH_ARP=@ZM_PATH_ARP@
|
ZM_PATH_ARP="@ZM_PATH_ARP@"
|
||||||
|
|
|
@ -149,7 +149,7 @@ BEGIN {
|
||||||
foreach my $str ( <$CONFIG> ) {
|
foreach my $str ( <$CONFIG> ) {
|
||||||
next if ( $str =~ /^\s*$/ );
|
next if ( $str =~ /^\s*$/ );
|
||||||
next if ( $str =~ /^\s*#/ );
|
next if ( $str =~ /^\s*#/ );
|
||||||
my ( $name, $value ) = $str =~ /^\s*([^=\s]+)\s*=\s*(.*?)\s*$/;
|
my ( $name, $value ) = $str =~ /^\s*([^=\s]+)\s*=\s*[\'"]*(.*?)[\'"]*\s*$/;
|
||||||
if ( ! $name ) {
|
if ( ! $name ) {
|
||||||
print( STDERR "Warning, bad line in $config_file: $str\n" );
|
print( STDERR "Warning, bad line in $config_file: $str\n" );
|
||||||
next;
|
next;
|
||||||
|
|
|
@ -123,9 +123,9 @@ void process_configfile( char* configFile) {
|
||||||
if ( *line_ptr == '\0' || *line_ptr == '#' )
|
if ( *line_ptr == '\0' || *line_ptr == '#' )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Remove trailing white space
|
// Remove trailing white space and trailing quotes
|
||||||
char *temp_ptr = line_ptr+strlen(line_ptr)-1;
|
char *temp_ptr = line_ptr+strlen(line_ptr)-1;
|
||||||
while ( *temp_ptr == ' ' || *temp_ptr == '\t' ) {
|
while ( *temp_ptr == ' ' || *temp_ptr == '\t' || *temp_ptr == '\'' || *temp_ptr == '\"') {
|
||||||
*temp_ptr-- = '\0';
|
*temp_ptr-- = '\0';
|
||||||
temp_ptr--;
|
temp_ptr--;
|
||||||
}
|
}
|
||||||
|
@ -147,8 +147,9 @@ void process_configfile( char* configFile) {
|
||||||
temp_ptr--;
|
temp_ptr--;
|
||||||
} while ( *temp_ptr == ' ' || *temp_ptr == '\t' );
|
} while ( *temp_ptr == ' ' || *temp_ptr == '\t' );
|
||||||
|
|
||||||
// Remove leading white space from the value part
|
// Remove leading white space and leading quotes from the value part
|
||||||
white_len = strspn( val_ptr, " \t" );
|
white_len = strspn( val_ptr, " \t" );
|
||||||
|
white_len += strspn( val_ptr, "\'\"" );
|
||||||
val_ptr += white_len;
|
val_ptr += white_len;
|
||||||
|
|
||||||
if ( strcasecmp( name_ptr, "ZM_DB_HOST" ) == 0 )
|
if ( strcasecmp( name_ptr, "ZM_DB_HOST" ) == 0 )
|
||||||
|
|
|
@ -212,7 +212,7 @@ function process_configfile($configFile) {
|
||||||
continue;
|
continue;
|
||||||
elseif ( preg_match( '/^\s*#/', $str ))
|
elseif ( preg_match( '/^\s*#/', $str ))
|
||||||
continue;
|
continue;
|
||||||
elseif ( preg_match( '/^\s*([^=\s]+)\s*=\s*(.*?)\s*$/', $str, $matches ))
|
elseif ( preg_match( '/^\s*([^=\s]+)\s*=\s*[\'"]*(.*?)[\'"]*\s*$/', $str, $matches ))
|
||||||
$configvals[$matches[1]] = $matches[2];
|
$configvals[$matches[1]] = $matches[2];
|
||||||
}
|
}
|
||||||
fclose( $cfg );
|
fclose( $cfg );
|
||||||
|
|
Loading…
Reference in New Issue