]> git.eshelyaron.com Git - emacs.git/commitdiff
Add a new way to encode unprintable characters in Message: url-encode
authorLars Ingebrigtsen <larsi@gnus.org>
Thu, 20 Aug 2020 14:42:06 +0000 (16:42 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 20 Aug 2020 14:42:06 +0000 (16:42 +0200)
* lisp/gnus/message.el (message-fix-before-sending): Add a new
conversion method for invalid characters -- URL-encoding (bug#38955).

lisp/gnus/message.el

index 0fd490be5c013a301bc853a667d99a3aaa479fcb..8ae5eb2f625bab23934c8bfeba6f00e716c4ebc9 100644 (file)
@@ -4466,6 +4466,7 @@ conformance."
                      ,(format
                        "Replace non-printable characters with \"%s\" and send"
                        message-replacement-char))
+                 (?u "url-encode" "Use URL %hex encoding")
                  (?s "send" "Send as is without removing anything")
                  (?e "edit" "Continue editing")))))
        (if (eq choice ?e)
@@ -4487,11 +4488,17 @@ conformance."
                                                     control-1))
                           (not (get-text-property
                                 (point) 'untranslated-utf-8)))))
-           (if (eq choice ?i)
-               (message-kill-all-overlays)
+           (cond
+            ((eq choice ?i)
+             (message-kill-all-overlays))
+            ((eq choice ?u)
+             (let ((char (get-byte (point))))
+               (delete-char 1)
+               (insert (format "%%%x" char))))
+            (t
              (delete-char 1)
              (when (eq choice ?r)
-               (insert message-replacement-char))))
+               (insert message-replacement-char)))))
          (forward-char)
          (skip-chars-forward mm-7bit-chars)))))
   (message-check 'bogus-recipient