Diff options
| -rw-r--r-- | source/parsing.c | 23 |
1 file changed, 11 insertions, 12 deletions
diff --git a/source/parsing.c b/source/parsing.c index d70a1ff..4c13c05 100644 --- a/source/parsing.c +++ b/source/parsing.c @@ -96,22 +96,21 @@ static int end_of_header(const char *p) * not UTF-8 has its stray bytes replaced, and a page declared UTF-8 never * carries any. */ -static const char *reencode(char **text, const char *from, const char *to) +static void reencode(char **text, const char *encoding) { char *converted; - if (!*text || !from || !to) - return *text; + if (!*text) + return; - if (strcasecmp(from, to)) { - converted = reencode_string(*text, to, from); + if (strcasecmp(encoding, PAGE_ENCODING)) { + converted = reencode_string(*text, PAGE_ENCODING, encoding); if (converted) { free(*text); *text = converted; } } cgit_utf8_sanitize(*text); - return *text; } /* @@ -222,12 +221,12 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) info->msg = xstrdup(""); } - reencode(&info->author, info->msg_encoding, PAGE_ENCODING); - reencode(&info->author_email, info->msg_encoding, PAGE_ENCODING); - reencode(&info->committer, info->msg_encoding, PAGE_ENCODING); - reencode(&info->committer_email, info->msg_encoding, PAGE_ENCODING); - reencode(&info->subject, info->msg_encoding, PAGE_ENCODING); - reencode(&info->msg, info->msg_encoding, PAGE_ENCODING); + reencode(&info->author, info->msg_encoding); + reencode(&info->author_email, info->msg_encoding); + reencode(&info->committer, info->msg_encoding); + reencode(&info->committer_email, info->msg_encoding); + reencode(&info->subject, info->msg_encoding); + reencode(&info->msg, info->msg_encoding); return info; } |
