Allow half quoted values
Previously config lines like [rule] script = mail -s "New notif" were only possible to get written with additional full quotes, which makes no sense in command line expressions.
This commit is contained in:
		
							parent
							
								
									357c4309e6
								
							
						
					
					
						commit
						6cc7ca361a
					
				| @ -203,16 +203,14 @@ int ini_get_bool(const char *section, const char *key, int def) | ||||
| 
 | ||||
| char *clean_value(const char *value) | ||||
| { | ||||
|         size_t len = strlen(value); | ||||
|         char *s; | ||||
| 
 | ||||
|         if (value[0] == '"') | ||||
|                 s = g_strdup(value + 1); | ||||
|         if (value[0] == '"' && value[len-1] == '"') | ||||
|                 s = g_strndup(value + 1, len-2); | ||||
|         else | ||||
|                 s = g_strdup(value); | ||||
| 
 | ||||
|         if (s[strlen(s) - 1] == '"') | ||||
|                 s[strlen(s) - 1] = '\0'; | ||||
| 
 | ||||
|         return s; | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -22,6 +22,7 @@ | ||||
| 	simple = A simple string | ||||
| 	quoted = "A quoted string" | ||||
| 	quoted_with_quotes = "A string "with quotes"" | ||||
| 	unquoted_with_quotes = A" string with quotes" | ||||
| 
 | ||||
| [path] | ||||
| 	expand_tilde    = ~/.path/to/tilde | ||||
|  | ||||
| @ -53,6 +53,8 @@ TEST test_ini_get_string(void) | ||||
|         free(ptr); | ||||
|         ASSERT_STR_EQ("A string \"with quotes\"", (ptr = ini_get_string(string_section, "quoted_with_quotes", ""))); | ||||
|         free(ptr); | ||||
|         ASSERT_STR_EQ("A\" string with quotes\"", (ptr = ini_get_string(string_section, "unquoted_with_quotes", ""))); | ||||
|         free(ptr); | ||||
| 
 | ||||
|         ASSERT_STR_EQ("default value", (ptr = ini_get_string(string_section, "nonexistent", "default value"))); | ||||
|         free(ptr); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Benedikt Heine
						Benedikt Heine