From 72131ff4ce5a63abcfacd357bf3120fd47054042 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Wed, 13 Sep 2017 13:03:40 +0200 Subject: [PATCH] Excludes: Allow escaping # #6012 Otherwise adding patterns that start with # are impossible to add, since they get treated as comments. Also add this escaping for patterns added in the ui. --- src/csync/csync_exclude.cpp | 1 + src/gui/ignorelisteditor.cpp | 2 ++ sync-exclude.lst | 2 ++ test/csync/csync_tests/check_csync_exclude.cpp | 4 ++-- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/csync/csync_exclude.cpp b/src/csync/csync_exclude.cpp index 7517ee218..7a177b840 100644 --- a/src/csync/csync_exclude.cpp +++ b/src/csync/csync_exclude.cpp @@ -84,6 +84,7 @@ static const char *csync_exclude_expand_escapes(const char * input) case '"': out[o++] = '"'; break; case '?': out[o++] = '?'; break; case '\\': out[o++] = '\\'; break; + case '#': out[o++] = '#'; break; case 'a': out[o++] = '\a'; break; case 'b': out[o++] = '\b'; break; case 'f': out[o++] = '\f'; break; diff --git a/src/gui/ignorelisteditor.cpp b/src/gui/ignorelisteditor.cpp index 64c39c48f..3253b2b1e 100644 --- a/src/gui/ignorelisteditor.cpp +++ b/src/gui/ignorelisteditor.cpp @@ -107,6 +107,8 @@ void IgnoreListEditor::slotUpdateLocalIgnoreList() QByteArray prepend; if (deletableItem->checkState() == Qt::Checked) { prepend = "]"; + } else if (patternItem->text().startsWith('#')) { + prepend = "\\"; } ignores.write(prepend + patternItem->text().toUtf8() + '\n'); } diff --git a/sync-exclude.lst b/sync-exclude.lst index bdf6c3441..fe5cbee10 100644 --- a/sync-exclude.lst +++ b/sync-exclude.lst @@ -1,3 +1,5 @@ +# This file contains fixed global exclude patterns + *~ ~$* .~lock.* diff --git a/test/csync/csync_tests/check_csync_exclude.cpp b/test/csync/csync_tests/check_csync_exclude.cpp index 99a771266..0525942ac 100644 --- a/test/csync/csync_tests/check_csync_exclude.cpp +++ b/test/csync/csync_tests/check_csync_exclude.cpp @@ -387,9 +387,9 @@ static void check_csync_exclude_expand_escapes(void **state) (void)state; const char *str = csync_exclude_expand_escapes( - "keep \\' \\\" \\? \\\\ \\a \\b \\f \\n \\r \\t \\v \\z"); + "keep \\' \\\" \\? \\\\ \\a \\b \\f \\n \\r \\t \\v \\z \\#"); assert_true(0 == strcmp( - str, "keep ' \" ? \\ \a \b \f \n \r \t \v \\z")); + str, "keep ' \" ? \\ \a \b \f \n \r \t \v \\z #")); SAFE_FREE(str); str = csync_exclude_expand_escapes("");