Correctly handle (?i) in ignores (fixes #1953)

This commit is contained in:
Jakob Borg
2015-09-02 20:54:18 +02:00
parent 70b37dc469
commit e3e1036dda
4 changed files with 21 additions and 27 deletions

View File

@@ -38,14 +38,6 @@ func Convert(pattern string, flags int) (*regexp.Regexp, error) {
}
}
// Support case insensitive ignores. We do the loop because we may in some
// circumstances end up with multiple insensitivity prefixes
// ("(?i)(?i)foo"), which should be accepted.
for ignore := strings.TrimPrefix(pattern, "(?i)"); ignore != pattern; ignore = strings.TrimPrefix(pattern, "(?i)") {
flags |= CaseFold
pattern = ignore
}
if flags&NoEscape != 0 {
pattern = strings.Replace(pattern, "\\", "\\\\", -1)
} else {