Excludes: Allow escaping # #6012
authorChristian Kamm <mail@ckamm.de>
Wed, 13 Sep 2017 11:03:40 +0000 (13:03 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Thu, 5 Oct 2017 20:01:06 +0000 (22:01 +0200)
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
src/gui/ignorelisteditor.cpp
sync-exclude.lst
test/csync/csync_tests/check_csync_exclude.cpp

index 7517ee218bfb2baa8a02deee1cb56aebeadb6331..7a177b840574c47980e754f95f4879dc4022e1df 100644 (file)
@@ -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;
index 64c39c48fe38c121987dea03f07792fe9e152d54..3253b2b1e5a0f3ad04cbde4ae5fc9ffe57f1af13 100644 (file)
@@ -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');
             }
index bdf6c34415553b4c1153d23e8aa84abf42febc47..fe5cbee106cefaaa93f4b1a353b74b70f5094628 100644 (file)
@@ -1,3 +1,5 @@
+# This file contains fixed global exclude patterns
+
 *~
 ~$*
 .~lock.*
index 99a771266290f820b6c0ab249f24c2d7f4045d0f..0525942ac15f6c55f14cb0a29d9feee10ec205d8 100644 (file)
@@ -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("");