summaryrefslogtreecommitdiff
path: root/parsing.c
diff options
context:
space:
mode:
authorLars Hjemli <hjemli@gmail.com>2011-03-26 15:22:35 +0100
committerLars Hjemli <hjemli@gmail.com>2011-03-26 15:22:35 +0100
commit568d8d3fd3f5a3b4207887215c8adcbac2bb9552 (patch)
treeb593858c82264a4e24d9051335b1a26b8bd0ebd7 /parsing.c
parent2e6721edbb3c94a70f4ef0ead5e55b9da19fb806 (diff)
parentfacca560d903351ddf1b8a41faafcd1f76de5c7c (diff)
Merge branch 'stable'
Diffstat (limited to 'parsing.c')
-rw-r--r--parsing.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/parsing.c b/parsing.c
index f37c49d..c9e4350 100644
--- a/parsing.c
+++ b/parsing.c
@@ -106,7 +106,11 @@ const char *reencode(char **txt, const char *src_enc, const char *dst_enc)
if (!txt || !*txt || !src_enc || !dst_enc)
return *txt;
- tmp = reencode_string(*txt, src_enc, dst_enc);
+ /* no encoding needed if src_enc equals dst_enc */
+ if(!strcasecmp(src_enc, dst_enc))
+ return *txt;
+
+ tmp = reencode_string(*txt, dst_enc, src_enc);
if (tmp) {
free(*txt);
*txt = tmp;
@@ -160,6 +164,10 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
}
}
+ /* if no special encoding is found, assume UTF-8 */
+ if(!ret->msg_encoding)
+ ret->msg_encoding = xstrdup("UTF-8");
+
// skip unknown header fields
while (p && *p && (*p != '\n')) {
p = strchr(p, '\n');
@@ -189,14 +197,12 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
} else
ret->subject = xstrdup(p);
- if (ret->msg_encoding) {
- reencode(&ret->author, PAGE_ENCODING, ret->msg_encoding);
- reencode(&ret->author_email, PAGE_ENCODING, ret->msg_encoding);
- reencode(&ret->committer, PAGE_ENCODING, ret->msg_encoding);
- reencode(&ret->committer_email, PAGE_ENCODING, ret->msg_encoding);
- reencode(&ret->subject, PAGE_ENCODING, ret->msg_encoding);
- reencode(&ret->msg, PAGE_ENCODING, ret->msg_encoding);
- }
+ reencode(&ret->author, ret->msg_encoding, PAGE_ENCODING);
+ reencode(&ret->author_email, ret->msg_encoding, PAGE_ENCODING);
+ reencode(&ret->committer, ret->msg_encoding, PAGE_ENCODING);
+ reencode(&ret->committer_email, ret->msg_encoding, PAGE_ENCODING);
+ reencode(&ret->subject, ret->msg_encoding, PAGE_ENCODING);
+ reencode(&ret->msg, ret->msg_encoding, PAGE_ENCODING);
return ret;
}