aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Engdegård2020-04-06 20:28:05 +0200
committerMattias Engdegård2020-04-06 23:51:40 +0200
commit8d95e75eb68745322a23424f1af5ab86f0cb0c3b (patch)
treec873663b904f728161a42f1901d0c44e70c48de4
parent8b04047653865c8d09cea8c852f7b29f33adb907 (diff)
downloademacs-8d95e75eb68745322a23424f1af5ab86f0cb0c3b.tar.gz
emacs-8d95e75eb68745322a23424f1af5ab86f0cb0c3b.zip
utf-7 and utf-7-imap are not ASCII-compatible (bug#40407)
* lisp/international/mule-conf.el (utf-7, utf-7-imap): Add expedient to disable the :ascii-compatible-p property set automatically by define-coding-system. * test/lisp/international/mule-tests.el (mule-utf-7): New test.
-rw-r--r--lisp/international/mule-conf.el5
-rw-r--r--test/lisp/international/mule-tests.el18
2 files changed, 23 insertions, 0 deletions
diff --git a/lisp/international/mule-conf.el b/lisp/international/mule-conf.el
index e6e6135243f..e5ea491a373 100644
--- a/lisp/international/mule-conf.el
+++ b/lisp/international/mule-conf.el
@@ -1517,6 +1517,9 @@ for decoding and encoding files, process I/O, etc."
1517 :charset-list '(unicode) 1517 :charset-list '(unicode)
1518 :pre-write-conversion 'utf-7-pre-write-conversion 1518 :pre-write-conversion 'utf-7-pre-write-conversion
1519 :post-read-conversion 'utf-7-post-read-conversion) 1519 :post-read-conversion 'utf-7-post-read-conversion)
1520;; FIXME: `define-coding-system' automatically sets :ascii-compatible-p,
1521;; but UTF-7 is not ASCII compatible; disable (bug#40407).
1522(coding-system-put 'utf-7 :ascii-compatible-p nil)
1520 1523
1521(define-coding-system 'utf-7-imap 1524(define-coding-system 'utf-7-imap
1522 "UTF-7 encoding of Unicode, IMAP version (RFC 2060)" 1525 "UTF-7 encoding of Unicode, IMAP version (RFC 2060)"
@@ -1525,6 +1528,8 @@ for decoding and encoding files, process I/O, etc."
1525 :charset-list '(unicode) 1528 :charset-list '(unicode)
1526 :pre-write-conversion 'utf-7-imap-pre-write-conversion 1529 :pre-write-conversion 'utf-7-imap-pre-write-conversion
1527 :post-read-conversion 'utf-7-imap-post-read-conversion) 1530 :post-read-conversion 'utf-7-imap-post-read-conversion)
1531;; See comment for utf-7 above.
1532(coding-system-put 'utf-7-imap :ascii-compatible-p nil)
1528 1533
1529;; Use us-ascii for terminal output if some other coding system is not 1534;; Use us-ascii for terminal output if some other coding system is not
1530;; specified explicitly. 1535;; specified explicitly.
diff --git a/test/lisp/international/mule-tests.el b/test/lisp/international/mule-tests.el
index 91e3c2279f0..bb96943888f 100644
--- a/test/lisp/international/mule-tests.el
+++ b/test/lisp/international/mule-tests.el
@@ -48,6 +48,24 @@
48 (append (kbd "C-x RET c u t f - 8 RET C-u C-u c a b RET") nil))) 48 (append (kbd "C-x RET c u t f - 8 RET C-u C-u c a b RET") nil)))
49 (read-string "prompt:"))))) 49 (read-string "prompt:")))))
50 50
51(ert-deftest mule-utf-7 ()
52 ;; utf-7 and utf-7-imap are not ASCII-compatible.
53 (should-not (coding-system-get 'utf-7 :ascii-compatible-p))
54 (should-not (coding-system-get 'utf-7-imap :ascii-compatible-p))
55 ;; Invariant ASCII subset.
56 (let ((s (apply #'string (append (number-sequence #x20 #x25)
57 (number-sequence #x27 #x7e)))))
58 (should (equal (encode-coding-string s 'utf-7-imap) s))
59 (should (equal (decode-coding-string s 'utf-7-imap) s)))
60 ;; Escaped ampersand.
61 (should (equal (encode-coding-string "a&bcd" 'utf-7-imap) "a&-bcd"))
62 (should (equal (decode-coding-string "a&-bcd" 'utf-7-imap) "a&bcd"))
63 ;; Ability to encode Unicode.
64 (should (equal (check-coding-systems-region "あ" nil '(utf-7-imap)) nil))
65 (should (equal (encode-coding-string "あ" 'utf-7-imap) "&MEI-"))
66 (should (equal (decode-coding-string "&MEI-" 'utf-7-imap) "あ")))
67
68
51;; Stop "Local Variables" above causing confusion when visiting this file. 69;; Stop "Local Variables" above causing confusion when visiting this file.
52 70
53 71