diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-11-05 18:07:07 +0300 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-11-05 18:22:01 +0300 |
commit | 5c54e2162a21cb909e961c62f53e7d4c64f80cb0 (patch) | |
tree | 6128e7ce82d0b8891bd469a652a67f7d6a403dc1 /src | |
parent | 4bb8708730e81c551ca70f47ebd875f236e7998f (diff) |
ignore: consider files with a CR in their names
We currently consider CR to start the end of the line, but that means
that we miss cases with CR CR LF which can be used with git to match
files whose names have CR at the end of their names.
The fix from the patch comes from Russell's comment in the issue.
This fixes #2536.
Diffstat (limited to 'src')
-rw-r--r-- | src/attr_file.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/attr_file.c b/src/attr_file.c index 07ffacbaf..562075291 100644 --- a/src/attr_file.c +++ b/src/attr_file.c @@ -543,7 +543,7 @@ int git_attr_fnmatch__parse( for (scan = pattern; *scan != '\0'; ++scan) { /* scan until (non-escaped) white space */ if (git__isspace(*scan) && *(scan - 1) != '\\') { - if (!allow_space || (*scan != ' ' && *scan != '\t')) + if (!allow_space || (*scan != ' ' && *scan != '\t' && *scan != '\r')) break; } @@ -564,6 +564,15 @@ int git_attr_fnmatch__parse( if ((spec->length = scan - pattern) == 0) return GIT_ENOTFOUND; + /* + * Remove one trailing \r in case this is a CRLF delimited + * file, in the case of Icon\r\r\n, we still leave the first + * \r there to match against. + */ + if (pattern[spec->length - 1] == '\r') + if (--spec->length == 0) + return GIT_ENOTFOUND; + if (pattern[spec->length - 1] == '/') { spec->length--; spec->flags = spec->flags | GIT_ATTR_FNMATCH_DIRECTORY; |