Diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
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.
Diffstat (limited to 'source')
-rw-r--r--source/parsing.c23
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;
}