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.
This commit is contained in:
Christian Kamm 2017-09-13 13:03:40 +02:00 committed by Roeland Jago Douma
parent c03d53e1dd
commit 72131ff4ce
No known key found for this signature in database
GPG Key ID: F941078878347C0C
4 changed files with 7 additions and 2 deletions

View 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;

View 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');
}

View File

@ -1,3 +1,5 @@
# This file contains fixed global exclude patterns
*~
~$*
.~lock.*

View 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("");