summaryrefslogtreecommitdiffabout
authorJonathan Bastien-Filiatrault <joe@x2a.org>2007-10-26 22:13:41 (UTC)
committer Jonathan Bastien-Filiatrault <joe@x2a.org>2007-11-05 23:13:31 (UTC)
commit7858a309d7671109950ec940f893c2d112d36b99 (patch) (unidiff)
tree676723bafc103e232341aa05be4d57ed773b9feb
parentaf0819830445e39584a0137034562086a55deaf2 (diff)
downloadcgit-7858a309d7671109950ec940f893c2d112d36b99.zip
cgit-7858a309d7671109950ec940f893c2d112d36b99.tar.gz
cgit-7858a309d7671109950ec940f893c2d112d36b99.tar.bz2
Convert subject and message with iconv_msg.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--parsing.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/parsing.c b/parsing.c
index f156c12..c731084 100644
--- a/parsing.c
+++ b/parsing.c
@@ -291,64 +291,78 @@ struct commitinfo *cgit_parse_commit(struct commit *commit)
291 ret->committer_date = atol(++t); 291 ret->committer_date = atol(++t);
292 p = strchr(t, '\n') + 1; 292 p = strchr(t, '\n') + 1;
293 } 293 }
294 294
295 if (!strncmp(p, "encoding ", 9)) { 295 if (!strncmp(p, "encoding ", 9)) {
296 p += 9; 296 p += 9;
297 t = strchr(p, '\n') + 1; 297 t = strchr(p, '\n') + 1;
298 ret->msg_encoding = substr(p, t); 298 ret->msg_encoding = substr(p, t);
299 p = t; 299 p = t;
300 } else 300 } else
301 ret->msg_encoding = xstrdup(PAGE_ENCODING); 301 ret->msg_encoding = xstrdup(PAGE_ENCODING);
302 302
303 while (*p && (*p != '\n')) 303 while (*p && (*p != '\n'))
304 p = strchr(p, '\n') + 1; // skip unknown header fields 304 p = strchr(p, '\n') + 1; // skip unknown header fields
305 305
306 while (*p == '\n') 306 while (*p == '\n')
307 p = strchr(p, '\n') + 1; 307 p = strchr(p, '\n') + 1;
308 308
309 t = strchr(p, '\n'); 309 t = strchr(p, '\n');
310 if (t) { 310 if (t) {
311 if (*t == '\0') 311 if (*t == '\0')
312 ret->subject = "** empty **"; 312 ret->subject = "** empty **";
313 else 313 else
314 ret->subject = substr(p, t); 314 ret->subject = substr(p, t);
315 p = t + 1; 315 p = t + 1;
316 316
317 while (*p == '\n') 317 while (*p == '\n')
318 p = strchr(p, '\n') + 1; 318 p = strchr(p, '\n') + 1;
319 ret->msg = xstrdup(p); 319 ret->msg = xstrdup(p);
320 } else 320 } else
321 ret->subject = substr(p, p+strlen(p)); 321 ret->subject = substr(p, p+strlen(p));
322 322
323 if(strcmp(ret->msg_encoding, PAGE_ENCODING)) {
324 t = iconv_msg(ret->subject, ret->msg_encoding);
325 if(t) {
326 free(ret->subject);
327 ret->subject = t;
328 }
329
330 t = iconv_msg(ret->msg, ret->msg_encoding);
331 if(t) {
332 free(ret->msg);
333 ret->msg = t;
334 }
335 }
336
323 return ret; 337 return ret;
324} 338}
325 339
326 340
327struct taginfo *cgit_parse_tag(struct tag *tag) 341struct taginfo *cgit_parse_tag(struct tag *tag)
328{ 342{
329 void *data; 343 void *data;
330 enum object_type type; 344 enum object_type type;
331 unsigned long size; 345 unsigned long size;
332 char *p, *t; 346 char *p, *t;
333 struct taginfo *ret; 347 struct taginfo *ret;
334 348
335 data = read_sha1_file(tag->object.sha1, &type, &size); 349 data = read_sha1_file(tag->object.sha1, &type, &size);
336 if (!data || type != OBJ_TAG) { 350 if (!data || type != OBJ_TAG) {
337 free(data); 351 free(data);
338 return 0; 352 return 0;
339 } 353 }
340 354
341 ret = xmalloc(sizeof(*ret)); 355 ret = xmalloc(sizeof(*ret));
342 ret->tagger = NULL; 356 ret->tagger = NULL;
343 ret->tagger_email = NULL; 357 ret->tagger_email = NULL;
344 ret->tagger_date = 0; 358 ret->tagger_date = 0;
345 ret->msg = NULL; 359 ret->msg = NULL;
346 360
347 p = data; 361 p = data;
348 362
349 while (p && *p) { 363 while (p && *p) {
350 if (*p == '\n') 364 if (*p == '\n')
351 break; 365 break;
352 366
353 if (!strncmp(p, "tagger ", 7)) { 367 if (!strncmp(p, "tagger ", 7)) {
354 p += 7; 368 p += 7;