- (when (eq c ?*)
- (setq encoded t)
- (forward-char 1)
- (setq c (char-after)))))
- ;; See if we have any previous continuations.
- (when (and prev-attribute
- (not (eq prev-attribute attribute)))
- (push (cons prev-attribute prev-value) parameters)
- (setq prev-attribute nil
- prev-value ""))
- (unless (eq c ?=)
- (error "Invalid header: %s" string))
- (forward-char 1)
- (setq c (char-after))
- (cond
- ((eq c ?\")
- (setq value
- (buffer-substring (1+ (point))
- (progn (forward-sexp 1) (1- (point))))))
- ((and (memq c ttoken)
- (not (memq c stoken)))
- (setq value (buffer-substring
- (point) (progn (forward-sexp 1) (point)))))
- (t
- (error "Invalid header: %s" string)))
- (when encoded
- (setq value (rfc2231-decode-encoded-string value)))
- (if number
- (setq prev-attribute attribute
- prev-value (concat prev-value value))
- (push (cons attribute value) parameters)))
+ (if (not (memq c ntoken))
+ (setq encoded t
+ number nil)
+ (setq number
+ (string-to-number
+ (buffer-substring
+ (point) (progn (forward-sexp 1) (point)))))
+ (setq c (char-after))
+ (when (eq c ?*)
+ (setq encoded t)
+ (forward-char 1)
+ (setq c (char-after)))))
+ ;; See if we have any previous continuations.
+ (when (and prev-attribute
+ (not (eq prev-attribute attribute)))
+ (push (cons prev-attribute
+ (if prev-encoded
+ (rfc2231-decode-encoded-string prev-value)
+ prev-value))
+ parameters)
+ (setq prev-attribute nil
+ prev-value ""
+ prev-encoded nil))
+ (unless (eq c ?=)
+ (error "Invalid header: %s" string))
+ (forward-char 1)
+ (setq c (char-after))
+ (cond
+ ((eq c ?\")
+ (setq value
+ (buffer-substring (1+ (point))
+ (progn (forward-sexp 1) (1- (point))))))
+ ((and (or (memq c ttoken)
+ (> c ?\177)) ;; EXTENSION: Support non-ascii chars.
+ (not (memq c stoken)))
+ (setq value (buffer-substring
+ (point)
+ (progn
+ (forward-sexp)
+ ;; We might not have reached at the end of
+ ;; the value because of non-ascii chars,
+ ;; so we should jump over them if any.
+ (while (and (not (eobp))
+ (> (char-after) ?\177))
+ (forward-char 1)
+ (forward-sexp))
+ (point)))))
+ (t
+ (error "Invalid header: %s" string)))
+ (if number
+ (setq prev-attribute attribute
+ prev-value (concat prev-value value)
+ prev-encoded encoded)
+ (push (cons attribute
+ (if encoded
+ (rfc2231-decode-encoded-string value)
+ value))
+ parameters))))