Browse Source

conf: support space in filename

Nick Peng 2 years ago
parent
commit
53593ba5b6
2 changed files with 5 additions and 5 deletions
  1. 3 3
      package/openwrt/files/etc/init.d/smartdns
  2. 2 2
      src/lib/conf.c

+ 3 - 3
package/openwrt/files/etc/init.d/smartdns

@@ -283,7 +283,7 @@ load_domain_rules()
 
 	config_get forwarding_domain_set_file "$section" "forwarding_domain_set_file" ""
 	[ ! -z "$forwarding_domain_set_file" ] && {
-		conf_append "domain-set" "-name ${domain_set_name}-forwarding-file -file $forwarding_domain_set_file"
+		conf_append "domain-set" "-name ${domain_set_name}-forwarding-file -file '$forwarding_domain_set_file'"
 		conf_append "domain-rules" "/domain-set:${domain_set_name}-forwarding-file/ $domain_set_args"
 	}
 
@@ -292,7 +292,7 @@ load_domain_rules()
 
 	config_get block_domain_set_file "$section" "block_domain_set_file"
 	[ ! -z "$block_domain_set_file" ] && {
-		conf_append "domain-set" "-name ${domain_set_name}-block-file -file $block_domain_set_file"
+		conf_append "domain-set" "-name ${domain_set_name}-block-file -file '$block_domain_set_file'"
 		conf_append "domain-rules" "/domain-set:${domain_set_name}-block-file/ -group block"
 	}
 
@@ -361,7 +361,7 @@ conf_append_conf_files()
 	fi
 
 	[ -f "$fullpath" ] && {
-		conf_append "conf-file" "$fullpath"
+		conf_append "conf-file" "'$fullpath'"
 	}
 }
 

+ 2 - 2
src/lib/conf.c

@@ -219,8 +219,8 @@ static int conf_parse_args(char *key, char *value, int *argc, char **argv)
 			continue;
 		}
 
-		if (*ptr == '"' && start == NULL) {
-			sep_flag = '"';
+		if ((*ptr == '"' || *ptr == '\'') && start == NULL) {
+			sep_flag = *ptr;
 			start = NULL;
 		}