[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/org-mime 59bf130c76 113/118: secure tag should be at the b
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/org-mime 59bf130c76 113/118: secure tag should be at the beginning of email body |
Date: |
Wed, 5 Jan 2022 07:58:51 -0500 (EST) |
branch: elpa/org-mime
commit 59bf130c76c5d960142e085a4cc5e94e3d32d182
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
secure tag should be at the beginning of email body
---
org-mime.el | 45 +++++++++++++++++++++++++++++++--------------
test/org-mime-tests.el | 7 +++++--
2 files changed, 36 insertions(+), 16 deletions(-)
diff --git a/org-mime.el b/org-mime.el
index 0c6c39a239..8edc2e67bd 100644
--- a/org-mime.el
+++ b/org-mime.el
@@ -6,7 +6,7 @@
;; Maintainer: Chen Bin (redguardtoo)
;; Keywords: mime, mail, email, html
;; Homepage: http://github.com/org-mime/org-mime
-;; Version: 0.2.3
+;; Version: 0.2.4
;; Package-Requires: ((emacs "25.1"))
;; This file is not part of GNU Emacs.
@@ -475,10 +475,22 @@ CURRENT-FILE is used to calculate full path of images."
(re-search-backward org-mime-mail-signature-separator nil t nil)))
+(defmacro org-mime-extract-tag-in-current-buffer (beginning end result)
+ "Extract the text between BEGINNING and END and insert it into RESULT."
+ `(when (and ,beginning ,end (< ,beginning ,end))
+ (push (buffer-substring-no-properties ,beginning ,end) ,result)
+ ;; delete old tag
+ (delete-region ,beginning ,end)))
+
(defun org-mime-extract-non-org ()
"Extract content not in org format (gpg signature, attachments ...)."
(unless (org-region-active-p)
- (let* (rlt str b e (old-pos (point)))
+ (let* (secure-tags
+ part-tags
+ str
+ b
+ e
+ (old-pos (point)))
(goto-char (point-min))
(while (re-search-forward "<#secure \\|<#part " (point-max) t)
(setq str (match-string 0))
@@ -486,19 +498,16 @@ CURRENT-FILE is used to calculate full path of images."
(cond
;; one line gpg signature tag
((string-match "^<#secure " str)
- (setq e (line-end-position)))
+ (setq e (line-end-position))
+ (org-mime-extract-tag-in-current-buffer b e secure-tags))
;; multi-lines attachment
((string-match "^<#part " str)
(save-excursion
(unless (re-search-forward "<#/part>" (point-max) t)
(error (format "\"%s\" should have end tag." str)))
- (setq e (match-end 0)))))
-
- ;; delete tag
- (when (and b e (< b e))
- (push (buffer-substring-no-properties b e) rlt)
- (delete-region b e))
+ (setq e (match-end 0))
+ (org-mime-extract-tag-in-current-buffer b e part-tags))))
;; search next tag
(goto-char (point-min)))
@@ -506,7 +515,8 @@ CURRENT-FILE is used to calculate full path of images."
;; move cursor back to its original position
(goto-char old-pos)
- (nreverse rlt))))
+ (list :secure-tags (nreverse secure-tags)
+ :part-tags (nreverse part-tags)))))
;;;###autoload
(defun org-mime-htmlize ()
@@ -516,7 +526,9 @@ If called with an active region only export that region,
otherwise entire body."
(when org-mime-debug (message "org-mime-htmlize called"))
(let* ((region-p (org-region-active-p))
- (tags (org-mime-extract-non-org))
+ (all-tags (org-mime-extract-non-org))
+ (secure-tags (plist-get all-tags :secure-tags))
+ (part-tags (plist-get all-tags :part-tags))
(html-start (funcall org-mime-find-html-start
(or (and region-p (region-beginning))
(org-mime-mail-body-begin))))
@@ -537,12 +549,17 @@ If called with an active region only export that region,
otherwise entire body."
(delete-region html-start html-end)
(goto-char html-start)
+ ;; restore secure tags
+ (when secure-tags
+ (insert (mapconcat #'identity secure-tags "\n"))
+ (insert "\n"))
+
;; insert converted html
(org-mime-insert-html-content plain file html opts)
- ;; restore non-org tags
- (dolist (tag tags)
- (insert (concat "\n" tag "\n")))))
+ ;; restore part tags
+ (when part-tags
+ (insert (mapconcat #'identity part-tags "\n")))))
(defun org-mime-apply-html-hook (html)
"Apply HTML hook."
diff --git a/test/org-mime-tests.el b/test/org-mime-tests.el
index cdecd42f41..ff99255165 100644
--- a/test/org-mime-tests.el
+++ b/test/org-mime-tests.el
@@ -311,7 +311,10 @@
(insert content)
(message-mode)
(setq tags (org-mime-extract-non-org)))
- (should (string= (nth 0 tags) "<#part type=\"application/pdf\"
filename=\"1.pdl\" disposition=attachment>\n<#/part>"))
- (should (string= (nth 1 tags) "<#secure method=pgpmime mode=sign>"))))
+ (should (string= (nth 0 (plist-get tags :part-tags))
+ "<#part type=\"application/pdf\" filename=\"1.pdl\"
disposition=attachment>\n<#/part>"))
+
+ (should (string= (nth 0 (plist-get tags :secure-tags))
+ "<#secure method=pgpmime mode=sign>"))))
(ert-run-tests-batch-and-exit)
- [nongnu] elpa/org-mime e81651d848 084/118: clean code, (continued)
- [nongnu] elpa/org-mime e81651d848 084/118: clean code, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 9bb6351b25 085/118: un-bundled htmlize.el, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 2581fc2dd9 091/118: org-mime-confirm-when-no-multipart function + docs, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 8ad1218456 095/118: Combine two insert calls, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 2cbd5de7bd 100/118: general export options should always override buffer options, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime ecbc66f16a 106/118: fixed typo, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime c6a3d73e78 107/118: remove org-mime-default-header, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 04e6ce9db6 108/118: try fixing ci again, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime eb21c02ba8 109/118: fixed org subtree htmlize, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 21692f16ce 110/118: use buffer properties, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 59bf130c76 113/118: secure tag should be at the beginning of email body,
ELPA Syncer <=
- [nongnu] elpa/org-mime df99e631c5 031/118: quoted mail use modern UI style, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime e5e4c59022 103/118: fixed some typo, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 3b119a22be 112/118: handle file url on Windows elegantly, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime f7a45f5573 115/118: Upgrade test file to GPLv3, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 77c3f07ce4 046/118: documentation, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime e5c68b1c66 044/118: minor changes to docstrings for readability and style changes., ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime e35c367e7d 048/118: clean code, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 41ea9818b4 050/118: fix cc, bcc compiling error, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 0db41d5b4e 065/118: emergency fix of broken 0.1.4, ELPA Syncer, 2022/01/05
- [nongnu] elpa/org-mime 470808cc14 070/118: Added support for MAIL_FROM property, ELPA Syncer, 2022/01/05