[mew-dist 27361] < > を含むバウンダリでエラー

Hideyuki SHIRAI ( 白井秀行 ) shirai at example.com
2006年 10月 12日 (木) 12:54:27 JST


白井です。

ぼくが rfc2045 を読む限りでは、

5.1.  Syntax of the Content-Type Header Field

     parameter := attribute "=" value

     attribute := token
                  ; Matching of attributes
                  ; is ALWAYS case-insensitive.

     value := token / quoted-string

     token := 1*<any (US-ASCII) CHAR except SPACE, CTLs,
                 or tspecials>

     tspecials :=  "(" / ")" / "<" / ">" / "@" /
                   "," / ";" / ":" / "\" / <">
                   "/" / "[" / "]" / "?" / "="
                   ; Must be in quoted-string,
                   ; to use within parameter values

なので、quote すれば、

Content-Type: multipart/alternative; boundary="<abc>"

のような boundary も許されると思います。

# ここまででなにか勘違いしていたら叱ってください。

ところが、

(mew-addrstr-parse-value-list "multipart/mixed; boundary=\"abc\"")
=> ("multipart/mixed" "boundary=\"abc\"")  ;; OK

(mew-addrstr-parse-value-list "multipart/mixed; boundary=\"<abc>\"")
=> ("multipart/mixed" "abc") ;; NG 


となってなります。

最近、ダイレクトメール系で

User-Agent: Spiral/1.9; Messaging Agent

というのがこの形式の boundary を出してくるので、"No boundary" で
エラーになるのですが。ぼくの RFC の解釈が間違っていなければ

mew-addrstr-parse-syntax-list() の最後の方が


	  (save-match-data
	    (if (string-match "<\\([^>]+\\)>" tmp)
	     	(setq ret (cons (mew-match-string 1 tmp) ret))
	      (setq ret (cons (substring tmp 0 tmp-cnt) ret)))))) ;; end of catch

ではなくて、

	  (save-match-data
	    (cond
	     ((not ret)
	      (if (string-match "<\\([^>]+\\)>" tmp)
		  (setq ret (cons (mew-match-string 1 tmp) ret))
		(setq ret (cons (substring tmp 0 tmp-cnt) ret)))) ;; end of catch
	     (t
	      (if (and (not (string-match "^boundary=" tmp))
		       (string-match "<\\([^>]+\\)>" tmp))
		  (setq ret (cons (mew-match-string 1 tmp) ret))
		(setq ret (cons (substring tmp 0 tmp-cnt) ret)))))))) ;; end of catch

な感じにならないとダメだと思います。または

(string-match "^boundary=" tmp)

の部分を『attribute "="』を表わす正規表現にするか、ですが、どっ
ちにしろ、これは parameter だということを厳密に判断した方がよい
と思われますのでおまかせします ^^;;;

-- 
白井秀行 (mailto:shirai at example.com)



Mew-dist メーリングリストの案内