summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-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
@@ -108,3 +108,7 @@ const char *reencode(char **txt, const char *src_enc, const char *dst_enc)
- 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) {
@@ -162,2 +166,6 @@ 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
@@ -191,10 +199,8 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
- 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);