diff --git a/test/T050-new.sh b/test/T050-new.sh index bc20440b..69697c48 100755 --- a/test/T050-new.sh +++ b/test/T050-new.sh @@ -330,7 +330,6 @@ output=$(NOTMUCH_NEW --quiet 2>&1) test_expect_equal "$output" "" test_begin_subtest "leading/trailing whitespace in new.tags is ignored" -test_subtest_known_broken # avoid complications with leading spaces and "notmuch config" sed -i 's/^tags=.*$/tags= fu bar ; ; bar /' notmuch-config add_message diff --git a/test/T070-insert.sh b/test/T070-insert.sh index 9d29c859..ec170b30 100755 --- a/test/T070-insert.sh +++ b/test/T070-insert.sh @@ -235,7 +235,6 @@ test_json_nodes <<<"$output" \ 'new_tags:[0][0][0]["tags"] = ["bar", "foo"]' test_begin_subtest "leading/trailing whitespace in new.tags is ignored" -test_subtest_known_broken # avoid complications with leading spaces and "notmuch config" sed -i 's/^tags=.*$/tags= fu bar ; ; bar /' notmuch-config gen_insert_msg diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh index 912aaa1f..6c426ae8 100755 --- a/test/T590-libconfig.sh +++ b/test/T590-libconfig.sh @@ -273,7 +273,6 @@ test_expect_equal_file EXPECTED OUTPUT restore_database test_begin_subtest "notmuch_config_get_values (ignore leading/trailing whitespace)" -test_subtest_known_broken cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR} ${NOTMUCH_CONFIG} %NULL% { notmuch_config_values_t *values; diff --git a/util/string-util.c b/util/string-util.c index 9c46a81a..03d7648d 100644 --- a/util/string-util.c +++ b/util/string-util.c @@ -42,13 +42,15 @@ const char * strsplit_len (const char *s, char delim, size_t *len) { bool escaping = false; - size_t count = 0; + size_t count = 0, last_nonspace = 0; - /* Skip initial unescaped delimiters */ - while (*s && *s == delim) + /* Skip initial unescaped delimiters and whitespace */ + while (*s && (*s == delim || isspace (*s))) s++; while (s[count] && (escaping || s[count] != delim)) { + if (! isspace (s[count])) + last_nonspace = count; escaping = (s[count] == '\\'); count++; } @@ -56,7 +58,7 @@ strsplit_len (const char *s, char delim, size_t *len) if (count == 0) return NULL; - *len = count; + *len = last_nonspace + 1; return s; }