Skip to content

Commit 392c29d

Browse files
committed
Enable strict eword decoder by customizable variable
New variable eword-decode-decode-safely can enable/disable workarounds for non-safe encoded-words. * eword-decode.el (eword-decode-decode-safely): New variable. (eword-decode-encoded-words, eword-analyze-encoded-word): Refer to it.
1 parent d8cdd42 commit 392c29d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

eword-decode.el

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,11 @@ encoded-word, concatenate them, and decode it by charset. Otherwise,
509509
the decoder will fully decode each encoded-word before concatenating
510510
them.")
511511

512+
(defvar eword-decode-decode-safely t
513+
"*Non-nil means decoder decodes encoded-words safely. Encoded LF is
514+
converted to SPACE and quote decoded words when it is not quoted and
515+
contain non-atom special chars")
516+
512517
(defun eword-decode-encoded-words (words must-unfold)
513518
"Decode successive encoded-words in WORDS and return a decoded string.
514519
Each element of WORDS looks like (CHARSET LANGUAGE ENCODING ENCODED-TEXT
@@ -535,9 +540,10 @@ such as a version of Net$cape)."
535540
(condition-case err
536541
(prog1 (setq text (encoded-text-decode-string
537542
(nth 3 word) encoding))
538-
(dotimes (i (length text))
539-
(when (eq (aref text i) ?\n)
540-
(aset text i ?\s))))
543+
(when eword-decode-decode-safely
544+
(dotimes (i (length text))
545+
(when (eq (aref text i) ?\n)
546+
(aset text i ?\s)))))
541547
(error
542548
(message "%s" (error-message-string err))
543549
nil)))
@@ -709,7 +715,8 @@ be the result.")
709715
(setq words (eword-decode-encoded-words (nreverse words) must-unfold))
710716
(cons
711717
(cons 'atom
712-
(if (and (string-match (eval-when-compile
718+
(if (and eword-decode-decode-safely
719+
(string-match (eval-when-compile
713720
(concat "[" std11-special-char-list "]"))
714721
words)
715722
(null (eq (cdr (std11-analyze-quoted-string words 0))

0 commit comments

Comments
 (0)