Skip to content

Commit a68b824

Browse files
author
Daigo Matsubara
committed
fixed markup, escaping, and I18N
1 parent ee16aba commit a68b824

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/threadprint.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -242,17 +242,23 @@ static void format_thread_info(FILE *fp, struct emailinfo *email,
242242
struct emailinfo* subdir_email, FILE *fp_body,
243243
int threadnum, bool is_first)
244244
{
245-
char *subj;
245+
char *subj, *tmpname;
246246
char *href = NULL;
247247
char buffer[256];
248248
char *first_attributes = (is_first) ? " accesskey=\"j\" name=\"first\" id=\"first\"" : "";
249249

250+
#ifdef HAVE_ICONV
251+
subj = convchars(email->subject, "utf-8");
252+
tmpname = convchars(email->name, "utf-8");
253+
#else
250254
subj = convchars(email->subject, email->charset);
255+
tmpname = convchars(email->name, email->charset);
256+
#endif
251257

252258
if (set_files_by_thread) {
253259
int maybe_reply = 0;
254260
int is_reply = 1;
255-
fprintf(fp_body, "<a name =\"%.4d\"></a>", email->msgnum);
261+
fprintf(fp_body, "<a name =\"%.4d\" id=\"%.4d\"></a>", email->msgnum, email->msgnum);
256262
print_headers(fp_body, email, TRUE);
257263
if ((set_show_msg_links && set_show_msg_links != 4) || !set_usetable) {
258264
fprintf(fp_body, "</ul>\n");
@@ -273,22 +279,25 @@ static void format_thread_info(FILE *fp, struct emailinfo *email,
273279
if (set_indextable) {
274280
fprintf(fp,
275281
"<tr><td>%s<a href=\"%s\"%s><strong>%s</strong></a></td>"
276-
"<td nowrap><a name=\"%d\">%s</a></td>" "<td nowrap>%s</td></tr>\n",
282+
"<td nowrap><a name=\"%d\" id=\"%d\">%s</a></td>" "<td nowrap>%s</td></tr>\n",
277283
level > 1 ? "--&gt; " : "",
278284
href, first_attributes,
279-
subj, email->msgnum, email->name, getindexdatestr(email->date));
285+
subj, email->msgnum, email->msgnum, tmpname, getindexdatestr(email->date));
280286
}
281287
else {
282288
if (num_open_li[level] != 0) {
283289
fprintf (fp, "</li>\n");
284290
num_open_li[level]--;
285291
}
286292
fprintf(fp, "<li><a href=\"%s\"%s>%s</a>&nbsp;"
287-
"<a name=\"%d\"><em>%s</em></a>&nbsp;<em>(%s)</em>\n",
293+
"<a name=\"%d\" id=\"%d\"><em>%s</em></a>&nbsp;<em>(%s)</em>\n",
288294
href, first_attributes,
289-
subj, email->msgnum, email->name, getindexdatestr(email->date));
295+
subj, email->msgnum, email->msgnum, tmpname, getindexdatestr(email->date));
290296
}
291-
free(subj);
297+
if (subj)
298+
free(subj);
299+
if (tmpname)
300+
free(tmpname);
292301
++num_replies[level];
293302
if (!set_indextable)
294303
++num_open_li[level];

0 commit comments

Comments
 (0)