diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Cut text between characters, never inside one
The index description was cut at a byte count, which could split a multibyte character and leave an invalid sequence on the page. Commit subjects already backed up to the start of the character, so html_ntxt now does that for every caller.
Diffstat (limited to '')
-rw-r--r--source/ui-shared.c8
1 file changed, 1 insertion, 7 deletions
diff --git a/source/ui-shared.c b/source/ui-shared.c
index 7d28c39..f3d815f 100644
--- a/source/ui-shared.c
+++ b/source/ui-shared.c
@@ -1039,13 +1039,7 @@ void cgit_commit_link(const char *name, const char *title, const char *class,
html("'>");
if (name && name[0] != '\0') {
if (ctx.cfg.max_msg_len >= MIN_TRUNCATE_LEN && strlen(name) > (size_t)ctx.cfg.max_msg_len) {
- size_t len = ctx.cfg.max_msg_len - ELLIPSIS_LEN;
-
- // A cut inside a multibyte character would leave an
- // invalid sequence on the page.
- while (len > 0 && (name[len] & 0xC0) == 0x80)
- len--;
- html_ntxt(name, len);
+ html_ntxt(name, ctx.cfg.max_msg_len - ELLIPSIS_LEN);
html("...");
} else {
html_txt(name);