summaryrefslogtreecommitdiff
path: root/src/signature.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2015-10-21 11:58:44 +0200
committerVicent Marti <tanoku@gmail.com>2015-10-21 11:58:44 +0200
commit307c4a2b6d1e3b403225b3d5b7f9894b940b24bd (patch)
tree39ca4dc5e8ce8b88e698145604cf3e60bc101bea /src/signature.c
parent4280fabb9f79df6c4d95b1f08b97a03874b167eb (diff)
downloadlibgit2-307c4a2b6d1e3b403225b3d5b7f9894b940b24bd.tar.gz
signature: Strip crud just like Git does
Diffstat (limited to 'src/signature.c')
-rw-r--r--src/signature.c18
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--;
}