From 8c89d0647328ad60ea1b6f4225619e0e154511f7 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 13:32:10 -0700 Subject: Drop reencode's fixed target and unread result Every call converted into the page encoding and dropped what came back, and a commit's encoding is always set by the time it runs. --- source/parsing.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'source/parsing.c') 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; } -- cgit