From: hmurata Date: Tue, 7 Jun 2005 08:52:50 +0000 (+0000) Subject: * elmo-util.el (elmo-token-valid-p): New function. X-Git-Tag: wl-2_15_3~69 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54152a39d50ffb2d2f3a7af77bca98fa1847192e;p=elisp%2Fwanderlust.git * elmo-util.el (elmo-token-valid-p): New function. (elmo-parse-token): Add optional argument `requirement'. (elmo-parse-prefixed-element): Likewise. * elmo-net.el (elmo-net-quote-chars): Renamed from `elmo-net-quote-chars-regexp'. (elmo-net-format-quoted): Add optional argument `extra-chars'. * elmo-pop3.el (elmo-folder-initialize): Fix the token separators by info document. Check token `uidl' is started an alphabet. * elmo-nntp.el (elmo-folder-initialize): Fix the token separators by info document. Check token `user' is started an alphabet. * elmo-imap4.el (elmo-folder-initialize): Ditto. (elmo-folder-list-subfolders): Quote user. --- diff --git a/elmo/ChangeLog b/elmo/ChangeLog index f76ef43..6faa594 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,3 +1,22 @@ +2005-06-07 Hiroya Murata + + * elmo-util.el (elmo-token-valid-p): New function. + (elmo-parse-token): Add optional argument `requirement'. + (elmo-parse-prefixed-element): Likewise. + + * elmo-net.el (elmo-net-quote-chars): Renamed from + `elmo-net-quote-chars-regexp'. + (elmo-net-format-quoted): Add optional argument `extra-chars'. + + * elmo-pop3.el (elmo-folder-initialize): Fix the token separators + by info document. Check token `uidl' is started an alphabet. + + * elmo-nntp.el (elmo-folder-initialize): Fix the token separators + by info document. Check token `user' is started an alphabet. + + * elmo-imap4.el (elmo-folder-initialize): Ditto. + (elmo-folder-list-subfolders): Quote user. + 2005-06-05 Hiroya Murata * elmo-util.el (elmo-quoted-specials-list): New constant. diff --git a/elmo/elmo-imap4.el b/elmo/elmo-imap4.el index 4b59548..978a3bc 100644 --- a/elmo/elmo-imap4.el +++ b/elmo/elmo-imap4.el @@ -1852,18 +1852,19 @@ Return nil if no complete line has arrived." (setq default-user (elmo-match-string 1 default-server)) (setq default-server (elmo-match-string 2 default-server))) ;; mailbox - (setq parse (elmo-parse-token name ":/@")) + (setq parse (elmo-parse-token name ":@:!")) (elmo-imap4-folder-set-mailbox-internal folder (elmo-imap4-encode-folder-string (car parse))) ;; user - (setq parse (elmo-parse-prefixed-element ?: (cdr parse) "/@")) + (setq parse (elmo-parse-prefixed-element ?: (cdr parse) "/@:!" + "^[A-Za-z]+")) (elmo-net-folder-set-user-internal folder (if (eq (length (car parse)) 0) default-user (car parse))) ;; auth - (setq parse (elmo-parse-prefixed-element ?/ (cdr parse) "@")) + (setq parse (elmo-parse-prefixed-element ?/ (cdr parse) "@:!")) (elmo-net-folder-set-auth-internal folder (if (eq (length (car parse)) 0) @@ -1990,7 +1991,9 @@ Return nil if no complete line has arrived." elmo-imap4-default-user)) (not (eq (elmo-net-folder-auth-internal folder) (or elmo-imap4-default-authenticate-type 'clear)))) - (setq append-serv (concat ":" (elmo-net-folder-user-internal folder)))) + (setq append-serv (concat ":" + (elmo-net-format-quoted + (elmo-net-folder-user-internal folder) "/")))) (unless (eq (elmo-net-folder-auth-internal folder) (or elmo-imap4-default-authenticate-type 'clear)) (setq append-serv @@ -2041,7 +2044,7 @@ Return nil if no complete line has arrived." (cdr result))) folder (concat prefix (elmo-net-format-quoted - (elmo-imap4-decode-folder-string folder)) + (elmo-imap4-decode-folder-string folder) ":") (and append-serv (eval append-serv))) ret (append ret (if has-child-p @@ -2051,7 +2054,7 @@ Return nil if no complete line has arrived." (mapcar (lambda (fld) (concat prefix (elmo-net-format-quoted - (elmo-imap4-decode-folder-string fld)) + (elmo-imap4-decode-folder-string fld) ":") (and append-serv (eval append-serv)))) result)))) diff --git a/elmo/elmo-net.el b/elmo/elmo-net.el index efef0ee..e4c6ecc 100644 --- a/elmo/elmo-net.el +++ b/elmo/elmo-net.el @@ -310,10 +310,11 @@ Returned value is searched from `elmo-network-stream-type-alist'." (setq alist (cdr alist))) spec)) -(defconst elmo-net-quote-chars-regexp "[@:!]") +(defconst elmo-net-quote-chars "@:!") -(defun elmo-net-format-quoted (string) - (if (string-match elmo-net-quote-chars-regexp string) +(defun elmo-net-format-quoted (string &optional extra-chars) + (if (string-match (concat "[" elmo-net-quote-chars extra-chars "]") + string) (elmo-quoted-token string) string)) diff --git a/elmo/elmo-nntp.el b/elmo/elmo-nntp.el index 120ae00..0a2ab4e 100644 --- a/elmo/elmo-nntp.el +++ b/elmo/elmo-nntp.el @@ -95,12 +95,13 @@ Debug information is inserted in the buffer \"*NNTP DEBUG*\"") elmo-network-stream-type-alist)) elmo-network-stream-type-alist)) explicit-user parse) - (setq parse (elmo-parse-token name ":@")) + (setq parse (elmo-parse-token name ":@!")) (elmo-nntp-folder-set-group-internal folder (elmo-nntp-encode-group-string (car parse))) (setq explicit-user (eq ?: (string-to-char (cdr parse)))) - (setq parse (elmo-parse-prefixed-element ?: (cdr parse) "@")) + (setq parse (elmo-parse-prefixed-element ?: (cdr parse) "@:!" + "^[A-Za-z]+")) (elmo-net-folder-set-user-internal folder (if (eq (length (car parse)) 0) (unless explicit-user diff --git a/elmo/elmo-pop3.el b/elmo/elmo-pop3.el index 0a7585f..6a78d94 100644 --- a/elmo/elmo-pop3.el +++ b/elmo/elmo-pop3.el @@ -95,19 +95,19 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"") elmo-network-stream-type-alist)) parse) ;; user - (setq parse (elmo-parse-token name "/:@")) + (setq parse (elmo-parse-token name "/@:!")) (elmo-net-folder-set-user-internal folder (if (eq (length (car parse)) 0) elmo-pop3-default-user (car parse))) ;; auth - (setq parse (elmo-parse-prefixed-element ?/ (cdr parse) ":@")) + (setq parse (elmo-parse-prefixed-element ?/ (cdr parse) ":@!")) (elmo-net-folder-set-auth-internal folder (if (eq (length (car parse)) 0) elmo-pop3-default-authenticate-type (intern (downcase (car parse))))) ;; uidl - (setq parse (elmo-parse-prefixed-element ?: (cdr parse) "@")) + (setq parse (elmo-parse-prefixed-element ?: (cdr parse) "@:!" "^[a-z]+")) (elmo-pop3-folder-set-use-uidl-internal folder (if (eq (length (car parse)) 0) elmo-pop3-default-use-uidl diff --git a/elmo/elmo-util.el b/elmo/elmo-util.el index e3768c1..88a9741 100644 --- a/elmo/elmo-util.el +++ b/elmo/elmo-util.el @@ -1457,7 +1457,14 @@ ELT must be a string. Upper-case and lower-case letters are treated as equal." (std11-wrap-as-quoted-pairs string elmo-quoted-specials-list) "\"")) -(defun elmo-parse-token (string &optional seps) +(defun elmo-token-valid-p (token requirement) + (cond ((null requirement)) + ((stringp requirement) + (string-match requirement token)) + ((functionp requirement) + (funcall requirement token)))) + +(defun elmo-parse-token (string &optional seps requirement) "Parse atom from STRING using SEPS as a string of separator char list." (let ((len (length string)) (seps (and seps (string-to-char-list seps))) @@ -1483,14 +1490,21 @@ ELT must be a string. Upper-case and lower-case letters are treated as equal." (t (setq content (cons c content) i (1+ i))))) (if in (error "Parse error in quoted")) - (cons (if (null content) "" (char-list-to-string (nreverse content))) - (substring string i))))) - -(defun elmo-parse-prefixed-element (prefix string &optional seps) - (if (and (not (eq (length string) 0)) - (eq (aref string 0) prefix)) - (elmo-parse-token (substring string 1) seps) - (cons "" string))) + (let ((atom (if (null content) + "" + (char-list-to-string (nreverse content))))) + (if (elmo-token-valid-p atom requirement) + (cons atom (substring string i)) + (cons "" string)))))) + +(defun elmo-parse-prefixed-element (prefix string &optional seps requirement) + (let (parsed) + (if (and (not (eq (length string) 0)) + (eq (aref string 0) prefix) + (setq parsed (elmo-parse-token (substring string 1) seps)) + (elmo-token-valid-p (car parsed) requirement)) + parsed + (cons "" string)))) ;;; Number set defined by OKAZAKI Tetsurou ;;