diff options
| author | Vicent Marti <tanoku@gmail.com> | 2015-10-21 11:58:44 +0200 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2015-10-21 11:58:44 +0200 |
| commit | 307c4a2b6d1e3b403225b3d5b7f9894b940b24bd (patch) | |
| tree | 39ca4dc5e8ce8b88e698145604cf3e60bc101bea /src/signature.c | |
| parent | 4280fabb9f79df6c4d95b1f08b97a03874b167eb (diff) | |
| download | libgit2-307c4a2b6d1e3b403225b3d5b7f9894b940b24bd.tar.gz | |
signature: Strip crud just like Git does
Diffstat (limited to 'src/signature.c')
| -rw-r--r-- | src/signature.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/signature.c b/src/signature.c index 818cd300e..109476efe 100644 --- a/src/signature.c +++ b/src/signature.c @@ -34,13 +34,27 @@ static bool contains_angle_brackets(const char *input) return strchr(input, '<') != NULL || strchr(input, '>') != NULL; } +static bool is_crud(unsigned char c) +{ + return c <= 32 || + c == '.' || + c == ',' || + c == ':' || + c == ';' || + c == '<' || + c == '>' || + c == '"' || + c == '\\' || + c == '\''; +} + static char *extract_trimmed(const char *ptr, size_t len) { - while (len && git__isspace(ptr[0])) { + while (len && is_crud((unsigned char)ptr[0])) { ptr++; len--; } - while (len && git__isspace(ptr[len - 1])) { + while (len && is_crud((unsigned char)ptr[len - 1])) { len--; } |
