Skip to content

Instantly share code, notes, and snippets.

@ikazuhiro
Created August 9, 2016 23:13
Show Gist options
  • Save ikazuhiro/8f89f4ea07100404a48b34423516807f to your computer and use it in GitHub Desktop.
Save ikazuhiro/8f89f4ea07100404a48b34423516807f to your computer and use it in GitHub Desktop.
Fix the case encoded-word contains special chars.
diff --git a/eword-decode.el b/eword-decode.el
index 59d72e3..f75b87e 100644
--- a/eword-decode.el
+++ b/eword-decode.el
@@ -739,9 +739,17 @@ be the result.")
(setq match (and (string-match regexp string next)
(= next (match-beginning 0)))))
(when words
- (cons (cons 'atom (eword-decode-encoded-words (nreverse words)
- must-unfold))
- next))))
+ (setq words (eword-decode-encoded-words (nreverse words) must-unfold))
+ (cons
+ (cons 'atom
+ (if (and (string-match std11-non-atom-regexp words)
+ (null (eq (cdr (std11-analyze-quoted-string words 0))
+ (length words))))
+ ;; Docoded words contains non-atom special chars and are
+ ;; not quoted.
+ (std11-wrap-as-quoted-string words)
+ words))
+ next))))
(defun eword-analyze-atom (string start &optional must-unfold)
(if (and (string-match std11-atom-regexp string start)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment