mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 19:08:58 +00:00
Merge pull request #2135 from calmh/caseinsign
Handle multiple case insensitivity prefixes in ignores (fixes #2134)
This commit is contained in:
commit
dad1fb7805
@ -38,9 +38,10 @@ func Convert(pattern string, flags int) (*regexp.Regexp, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Support case insensitive ignores
|
// Support case insensitive ignores. We do the loop because we may in some
|
||||||
ignore := strings.TrimPrefix(pattern, "(?i)")
|
// circumstances end up with multiple insensitivity prefixes
|
||||||
if ignore != pattern {
|
// ("(?i)(?i)foo"), which should be accepted.
|
||||||
|
for ignore := strings.TrimPrefix(pattern, "(?i)"); ignore != pattern; ignore = strings.TrimPrefix(pattern, "(?i)") {
|
||||||
flags |= CaseFold
|
flags |= CaseFold
|
||||||
pattern = ignore
|
pattern = ignore
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ var testcases = []testcase{
|
|||||||
|
|
||||||
{"foo.txt", "foo.TXT", CaseFold, true},
|
{"foo.txt", "foo.TXT", CaseFold, true},
|
||||||
{"(?i)foo.txt", "foo.TXT", 0, true},
|
{"(?i)foo.txt", "foo.TXT", 0, true},
|
||||||
|
{"(?i)(?i)foo.txt", "foo.TXT", 0, true}, // repeated prefix should be fine
|
||||||
{"(?i)**foo.txt", "/dev/tmp/foo.TXT", 0, true},
|
{"(?i)**foo.txt", "/dev/tmp/foo.TXT", 0, true},
|
||||||
{"(?i)!**foo.txt", "/dev/tmp/foo.TXT", 0, false},
|
{"(?i)!**foo.txt", "/dev/tmp/foo.TXT", 0, false},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user