]> gitweb.ps.run Git - ps-cgit/blobdiff - parsing.c
Add some more decls from git (cache.h, tag.h)
[ps-cgit] / parsing.c
index 4d5cc743da1ec9c7143c825330e3bf0bfd4f8d45..4412dee7fcf398945a3161b5d98f733d1282b491 100644 (file)
--- a/parsing.c
+++ b/parsing.c
@@ -79,6 +79,25 @@ int cgit_read_config(const char *filename, configfn fn)
        return ret;
 }
 
+char *convert_query_hexchar(char *txt)
+{
+       int d1, d2;
+       if (strlen(txt) < 3) {
+               *txt = '\0';
+               return txt-1;
+       }
+       d1 = hextoint(*(txt+1));
+       d2 = hextoint(*(txt+2));
+       if (d1<0 || d2<0) {
+               strcpy(txt, txt+3);
+               return txt-1;
+       } else {
+               *txt = d1 * 16 + d2;
+               strcpy(txt+1, txt+3);
+               return txt;
+       }
+}
+
 int cgit_parse_query(char *txt, configfn fn)
 {
        char *t, *value = NULL, c;
@@ -92,6 +111,10 @@ int cgit_parse_query(char *txt, configfn fn)
                if (c=='=') {
                        *t = '\0';
                        value = t+1;
+               } else if (c=='+') {
+                       *t = ' ';
+               } else if (c=='%') {
+                       t = convert_query_hexchar(t);
                } else if (c=='&') {
                        *t = '\0';
                        (*fn)(txt, value);
@@ -122,6 +145,12 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
 
        ret = xmalloc(sizeof(*ret));
        ret->commit = commit;
+       ret->author = NULL;
+       ret->author_email = NULL;
+       ret->committer = NULL;
+       ret->committer_email = NULL;
+       ret->subject = NULL;
+       ret->msg = NULL;
 
        if (strncmp(p, "tree ", 5))
                die("Bad commit: %s", sha1_to_hex(commit->object.sha1));
@@ -157,12 +186,13 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
                p = strchr(p, '\n') + 1;
 
        t = strchr(p, '\n');
-       ret->subject = substr(p, t);
-       p = t + 1;
-
-       while (*p == '\n')
-               p = strchr(p, '\n') + 1;
-       ret->msg = p;
+       if (t && *t) {
+               ret->subject = substr(p, t);
+               p = t + 1;
 
+               while (*p == '\n')
+                       p = strchr(p, '\n') + 1;
+               ret->msg = p;
+       }
        return ret;
 }