Skip to content

Commit

Permalink
Excludes: Allow escaping # owncloud#6012
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ckamm committed Sep 14, 2017
1 parent 8392d6c commit 0b7ad2c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/csync/csync_exclude.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/gui/ignorelisteditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
2 changes: 2 additions & 0 deletions sync-exclude.lst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This file contains fixed global exclude patterns

*~
~$*
.~lock.*
Expand Down
4 changes: 2 additions & 2 deletions test/csync/csync_tests/check_csync_exclude.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
Expand Down

0 comments on commit 0b7ad2c

Please sign in to comment.