Index: hypermail/README.jp diff -u /dev/null hypermail/README.jp:1.2 --- /dev/null Mon Mar 20 06:13:58 2000 +++ hypermail/README.jp Mon Mar 20 04:28:36 2000 @@ -0,0 +1,35 @@ +Mon Mar 20 03:28:29 JST 2000 + +hypermail で日本語メールを扱うパッチ + ちょっと修正 + +1. 日本語 + + 少なくとも次のケースでの日本語の表示を確認しています。 + + - メッセージ本文内の日本語 + 特に URL や e-mail アドレスの含まれる行に関して修正 + - "Subject: " に含まれる Base64 エンコードされた JIS コード + - "From: " に含まれる Base64 エンコードされた JIS コード + From: 後藤 久 + From: que@dti.que.ne.jp (後藤 久) + - 添付ファイルの日本語ファイル名 + 基本的に日本語が含まれるファイル名は信用しないことにしています。 + ただし Web では拡張子が有効である場合が多いので、ドット(.) 以 + 降の文字列が ASCII である場合に限って、元の拡張子を残していま + す。 + +2. ちょっと修正 + + (1) showhtml の振舞い + 設定ファイルに showhtml = 0 と指定するとメッセージ本文が +
..
で囲まれます。ですが Plain/Rfc822 として添付されたファ + イルは

..

となってしまうので、同じく
..
で囲うよ + うに修正しています。 + + (2) 添付ファイルのファイル名 + オリジナルではファイル名内の文字を安全な文字に置き換える処理を行なっ + ています。生成される HTML でも変換後のファイル名が表示されるのです + が、本パッチでは、表示にはオリジナルのファイル名を用いて、実際にアー + カイブするファイル名には変換後のファイル名を用いています。 + +Hisashi Gotoh Index: hypermail/src/getname.c diff -u hypermail/src/getname.c:1.1.1.1 hypermail/src/getname.c:1.3 --- hypermail/src/getname.c:1.1.1.1 Mon Mar 20 03:26:46 2000 +++ hypermail/src/getname.c Mon Mar 20 06:13:41 2000 @@ -67,6 +67,8 @@ char email[MAILSTRLEN]; char name[NAMESTRLEN]; + char *iso2022jp_ptr, *ascii_ptr, *line_tmp = line; + len = MAILSTRLEN - 1; comment_fnd = 0; @@ -82,7 +84,22 @@ /* EMail Processing First: ** First, is there an '@' sign we can use as an anchor ? */ - if ((c = strchr(line, '@')) == NULL) { + + /* lookup ascii ``@'' */ + while (1) { + if ((c = strchr(line_tmp, '@')) == 0) break; + + if ((iso2022jp_ptr = strstr(line_tmp, "\033$B")) == 0) + iso2022jp_ptr = strstr(line_tmp, "\033$J"); + if ((ascii_ptr = strstr(line_tmp, "\033(B")) == 0) + ascii_ptr = strstr(line_tmp, "\033(J"); + if (iso2022jp_ptr == 0 || ascii_ptr == 0) break; + + if (c < iso2022jp_ptr) break; + else line_tmp = ascii_ptr + 3; + } + + if (c == NULL) { /* ** No '@' sign here so ... */ @@ -174,9 +191,18 @@ comment_fnd = 1; } else if (strchr(line, '(')) { - c = strchr(line, '(') + 1; - if (*c == '"') /* is there a comment in the comment ? */ - c++; + c = strchr(line, '('); + if ((iso2022jp_ptr = strstr(line, "\033$B")) || + (iso2022jp_ptr = strstr(line, "\033$J"))); + if ((ascii_ptr = strstr(line, "\033(B")) || + (ascii_ptr = strstr(line, "\033(J"))); + if (iso2022jp_ptr && iso2022jp_ptr <=c && ascii_ptr) { + c = iso2022jp_ptr; + } else { + c++; + if (*c == '"') /* is there a comment in the comment ? */ + c++; + } } else if (*c == '<') { /* Comment may be on the end */ /* From: Bill Campbell */ @@ -229,9 +255,19 @@ if (!comment_fnd) { for (i = 0, len = NAMESTRLEN - 1; *c && *c != '<' && *c != '\"' && *c != ')' && *c != '(' && - *c != '\n' && i < len; c++) - name[i++] = *c; - + *c != '\n' && i < len; c++) { + if ((iso2022jp_ptr = strstr(c, "\033$B")) == 0) + iso2022jp_ptr = strstr(c, "\033$J"); + if ((ascii_ptr = strstr(c, "\033(B")) == 0) + ascii_ptr = strstr(c, "\033(J"); + if (c <= iso2022jp_ptr && c <= ascii_ptr + 3) { + for (; c < ascii_ptr + 3; c++) + name[i++] = *c; + c--; + } else { + name[i++] = *c; + } + } } if (*c == '<' || *c == '(') Index: hypermail/src/mprintf.c diff -u hypermail/src/mprintf.c:1.1.1.1 hypermail/src/mprintf.c:1.2 --- hypermail/src/mprintf.c:1.1.1.1 Mon Mar 20 03:26:46 2000 +++ hypermail/src/mprintf.c Mon Mar 20 04:37:37 2000 @@ -1051,7 +1051,7 @@ if(infop->length < infop->max) { /* only do this if we haven't reached max length yet */ - if (isprint(output) || isspace(output)) + if (isprint(output) || isspace(output) || output == '\033') { infop->buffer[0] = (char)output; /* store */ infop->buffer++; /* increase pointer */ Index: hypermail/src/parse.c diff -u hypermail/src/parse.c:1.1.1.1 hypermail/src/parse.c:1.2 --- hypermail/src/parse.c:1.1.1.1 Mon Mar 20 03:26:46 2000 +++ hypermail/src/parse.c Mon Mar 20 04:18:31 2000 @@ -289,6 +289,31 @@ register char *sp; register char *np; + /* for Japanese file name, +++ is Japanese characters. + ++++ -> NULL + ++++aaa -> NULL + aa+++++ -> NULL + +++++.doc -> .doc + +++aa.xls -> .xls + +++aa.bb+++ -> NULL + +++aa.+++cc -> NULL + */ + if ((strstr(name,"\033$B")) || (strstr(name,"\033$J"))) { + char *dot; + if ((dot = strrchr(name,'.'))) { + if ((strstr(dot,"\033(B")) || (strstr(dot,"\033(J"))) { + *name = '\0'; + } else { + char *tmp, *c; + for (tmp = name, c = dot; tmp < dot; tmp++, c++) { + *tmp = *c; + } + } + } else { + *name = '\0'; + } + } + np = name; while (*np && (*np == ' ' || *np == '\t')) np++; @@ -777,7 +802,9 @@ /* base64 decoding */ int len; base64Decode(ptr, output, &len); - output += len - 1; + output += len; + if (strcasecmp(charset,"iso-2022-jp") != 0) + output--; } else { /* unsupported encoding type */ @@ -1067,6 +1094,7 @@ FileStatus file_created = NO_FILE; /* for attachments */ char attachname[129]; /* for attachment file names */ + char attachname_keep[129]; /* for attachment file names (keep original) */ char inline_force = FALSE; /* show a attachment in-line, regardles of the content_disposition */ char *description = NULL; /* user-supplied description for an attachment */ @@ -1443,6 +1471,8 @@ if ('\"' == *fname) fname++; sscanf(fname, "%128[^\"]", attachname); + strncpy(attachname_keep,attachname, + sizeof(attachname)); safe_filename(attachname); } else { @@ -1981,12 +2011,16 @@ if (att_counter > 99) binname = NULL; else { - if (attachname[0]) - fname = attachname; + if (attachname[0]) { + if (attachname[0] == '.') + fname = maprintf("-%s%s",FILE_SUFFIXER,attachname); + else + fname = maprintf("-%s",attachname); + } else - fname = FILE_SUFFIXER; + fname = maprintf("-%s",FILE_SUFFIXER); - binname = maprintf("%s%c%.2d-%s", + binname = maprintf("%s%c%.2d%s", att_dir, PATH_SEPARATOR, att_counter, fname); /* @@ move this one up */ @@ -2071,7 +2105,7 @@ "picture"; else desc = - attachname[0] ? attachname : + attachname_keep[0] ? attachname_keep : "stored"; if (description) Index: hypermail/src/print.c diff -u hypermail/src/print.c:1.1.1.1 hypermail/src/print.c:1.2 --- hypermail/src/print.c:1.1.1.1 Mon Mar 20 03:26:46 2000 +++ hypermail/src/print.c Mon Mar 20 04:18:31 2000 @@ -505,6 +505,12 @@ } fprintf(fp, "

\n"); } + else { + if (!pre) { + fprintf(fp, "

\n");
+				pre = TRUE;
+			}
+		}
 		inheader = FALSE;
 	    }
 	}
Index: hypermail/src/printfile.c
diff -u hypermail/src/printfile.c:1.1.1.1 hypermail/src/printfile.c:1.2
--- hypermail/src/printfile.c:1.1.1.1	Mon Mar 20 03:26:46 2000
+++ hypermail/src/printfile.c	Mon Mar 20 04:18:31 2000
@@ -204,7 +204,8 @@
     title = maprintf("%s: %s", label, rp = convchars(subject));
     free(rp);
 
-    if (strlen(title) > TITLESTRLEN) {
+    if (strlen(title) > TITLESTRLEN &&
+	!strstr(title,"\033$B") && !strstr(title,"\033$J")) {
 	rp = title + (TITLESTRLEN - 1);
 	*rp-- = '\0';
     }
Index: hypermail/src/string.c
diff -u hypermail/src/string.c:1.1.1.1 hypermail/src/string.c:1.2
--- hypermail/src/string.c:1.1.1.1	Mon Mar 20 03:26:46 2000
+++ hypermail/src/string.c	Mon Mar 20 04:18:31 2000
@@ -382,12 +382,28 @@
 char *convchars(char *line)
 {
     struct Push buff;
+    char *esc_iso2022jp, *esc_ascii;
 
     INIT_PUSH(buff);		/* init macro */
 
     /* avoid strlen() for speed */
 
     for (; *line; line++) {
+	if ((esc_iso2022jp = strstr(line, "\033$B")) == 0)
+		esc_iso2022jp = strstr(line, "\033$J");
+	if (esc_iso2022jp != 0) {
+		if ((esc_ascii = strstr(line, "\033(B")) == 0)
+		    esc_ascii = strstr(line, "\033(J");
+		if (esc_iso2022jp <= line && line <= esc_ascii+2) {
+			/* while (line <= esc_ascii+2) { */
+			for (; line<=esc_ascii+2; line++) {
+				PushByte(&buff, *line);
+			}
+			line--;
+			continue;
+		}
+	}
+
 	switch (*line) {
 	case '<':
 	    PushString(&buff, "<");
@@ -453,8 +469,22 @@
 static void translatechars(char *start, char *end, struct Push *buff)
 {
     char *p;
+    char *esc_iso2022jp, *esc_ascii;
 
     for (p = start; p <= end; p++) {
+	if ((esc_iso2022jp = strstr(p, "\033$B")) == 0)
+		esc_iso2022jp = strstr(p, "\033$J");
+	if (esc_iso2022jp != 0) {
+		if ((esc_ascii = strstr(p, "\033(B")) == 0)
+		    esc_ascii = strstr(p, "\033(J");
+		if (esc_iso2022jp <= p && p <= esc_ascii+2) {
+			for (; p<=esc_ascii+2; p++) {
+				PushByte(buff, *p);
+			}
+			p--;
+			continue;
+		}
+	}
 
 	switch (*p) {
 
@@ -633,11 +663,27 @@
     char *ptr;
     char *lastpos = input;
     struct Push buff;
+    char *iso2022jp_ptr, *ascii_ptr;
 
     INIT_PUSH(buff);
 
     while (*input) {
-	if ((ptr = strchr(input, '@'))) {
+	/* lookup ascii ``@'' */
+	while (1) {
+		if ((ptr = strchr(input, '@')) == 0) break;
+
+		if ((iso2022jp_ptr = strstr(input, "\033$B")) == 0)
+			iso2022jp_ptr = strstr(input, "\033$J");
+		if ((ascii_ptr = strstr(input, "\033(B")) == 0)
+			ascii_ptr = strstr(input, "\033(J");
+		if (iso2022jp_ptr == 0 || ascii_ptr == 0) break;
+	
+		if (ptr < iso2022jp_ptr) break;
+		else input = ascii_ptr + 3;
+	}
+
+	/* if ((ptr = strchr(input, '@'))) { */
+	if (ptr) {
 	    /* found a @ */
 	    char *email = ptr - 1;
 	    char content[2];