(no subject)

classic Classic list List threaded Threaded
44 messages Options
123
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

(no subject)

This is the first allegedly complete version of support for gmime 3

It obsoletes several partial series [1][2]

   - id:[hidden email]
   - patches 9-11, starting at id:[hidden email]

There still remains the question of whether we should include

      [PATCH 10/23] test: test parsing of malformed from addresses

I'm not very optimistic about a fix coming along, and it's not
obviously a big issue for users.

The following are crypto related, and could particularly use review

[PATCH 01/23] emacs: convert to use format-version 3
[PATCH 02/23] devel/schemata: describe version 4
[PATCH 03/23] cli: implement structured output version 4
[PATCH 07/23] test/crypto: mark extra space in userid as a bug in
[PATCH 08/23] test: add test for modified pgp/mime signed message
[PATCH 09/23] test/crypto: add test for corrupted signatures
[PATCH 16/23] cli: generalize use of GMIME_SIGNATURE_{ERROR,STATUS}
[PATCH 17/23] cli: hide rename of GMimeCertificateTrust
[PATCH 22/23] cli: make keyid from fingerprint in gmime 3.0
[PATCH 23/23] cli: wrap getting uid
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 01/23] emacs: convert to use format-version 3

Keeping the emacs interface running old format-versions makes it
impossible to test new format-versions or deprecate old ones.
---
 emacs/notmuch-address.el | 2 +-
 emacs/notmuch-mua.el     | 2 +-
 emacs/notmuch-query.el   | 2 +-
 emacs/notmuch-show.el    | 3 ++-
 emacs/notmuch-tree.el    | 2 +-
 emacs/notmuch.el         | 2 +-
 test/T310-emacs.sh       | 2 +-
 test/T450-emacs-show.sh  | 2 +-
 8 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el
index d504ff2d..74a4584f 100644
--- a/emacs/notmuch-address.el
+++ b/emacs/notmuch-address.el
@@ -317,7 +317,7 @@ execution, CALLBACK is called when harvesting finishes."
     (when config-query
       (format " and (%s)" config-query)))
   from-or-to-me-query))
- (args `("address" "--format=sexp" "--format-version=2"
+ (args `("address" "--format=sexp" "--format-version=3"
  ,(if sent "--output=recipients" "--output=sender")
  "--deduplicate=address"
  ,query)))
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 93747b1c..ddfb9811 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -176,7 +176,7 @@ mutiple parts get a header."
   (unless (bolp) (insert "\n")))
 
 (defun notmuch-mua-reply (query-string &optional sender reply-all)
-  (let ((args '("reply" "--format=sexp" "--format-version=1"))
+  (let ((args '("reply" "--format=sexp" "--format-version=3"))
  (process-crypto notmuch-show-process-crypto)
  reply
  original)
diff --git a/emacs/notmuch-query.el b/emacs/notmuch-query.el
index 436ad160..48acb551 100644
--- a/emacs/notmuch-query.el
+++ b/emacs/notmuch-query.el
@@ -30,7 +30,7 @@ A thread is a forest or list of trees. A tree is a two element
 list where the first element is a message, and the second element
 is a possibly empty forest of replies.
 "
-  (let ((args '("show" "--format=sexp" "--format-version=1")))
+  (let ((args '("show" "--format=sexp" "--format-version=3")))
     (if notmuch-show-process-crypto
  (setq args (append args '("--decrypt"))))
     (setq args (append args search-terms))
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e7c22da0..21fcc036 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1660,9 +1660,10 @@ current thread."
 
 ;; dme: Would it make sense to use a macro for many of these?
 
+;; XXX TODO figure out what to do about multiple filenames
 (defun notmuch-show-get-filename ()
   "Return the filename of the current message."
-  (notmuch-show-get-prop :filename))
+  (car (notmuch-show-get-prop :filename)))
 
 (defun notmuch-show-get-header (header &optional props)
   "Return the named header of the current message, if any."
diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el
index d4d40761..6812d7e9 100644
--- a/emacs/notmuch-tree.el
+++ b/emacs/notmuch-tree.el
@@ -917,7 +917,7 @@ the same as for the function notmuch-tree."
     (notmuch-tag-clear-cache)
     (let ((proc (notmuch-start-notmuch
  "notmuch-tree" (current-buffer) #'notmuch-tree-process-sentinel
- "show" "--body=false" "--format=sexp" "--format-version=2"
+ "show" "--body=false" "--format=sexp" "--format-version=3"
  message-arg search-args))
   ;; Use a scratch buffer to accumulate partial output.
   ;; This buffer will be killed by the sentinel, which
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 40b9fabd..a4a7fd8b 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -990,7 +990,7 @@ the configured default sort order."
       (save-excursion
  (let ((proc (notmuch-start-notmuch
      "notmuch-search" buffer #'notmuch-search-process-sentinel
-     "search" "--format=sexp" "--format-version=2"
+     "search" "--format=sexp" "--format-version=3"
      (if oldest-first
  "--sort=oldest-first"
        "--sort=newest-first")
diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
index ef599849..8a881941 100755
--- a/test/T310-emacs.sh
+++ b/test/T310-emacs.sh
@@ -1014,7 +1014,7 @@ YYY/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)
 === ERROR ===
 [XXX]
 YYY/notmuch_fail exited with status 1
-command: YYY/notmuch_fail search --format\=sexp --format-version\=2 --sort\=newest-first tag\:inbox
+command: YYY/notmuch_fail search --format\=sexp --format-version\=3 --sort\=newest-first tag\:inbox
 exit status: 1"
 
 test_begin_subtest "Search handles subprocess warnings"
diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh
index 74d546bd..d302efb6 100755
--- a/test/T450-emacs-show.sh
+++ b/test/T450-emacs-show.sh
@@ -191,7 +191,7 @@ This is an error (see *Notmuch errors* for more details)
 === ERROR ===
 [XXX]
 This is an error
-command: YYY/notmuch_fail show --format\\=sexp --format-version\\=1 --exclude\\=false \\' \\* \\'
+command: YYY/notmuch_fail show --format\\=sexp --format-version\\=3 --exclude\\=false \\' \\* \\'
 exit status: 1
 stderr:
 This is an error
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 02/23] devel/schemata: describe version 4

In reply to this post by David Bremner-2
Replace numeric errors with human readable flags.  Not all sig_error
keys will necessarily be generated with a given version of gmime.

Drop status "none" as it's currrently unused and I don't know what
it's for.
---
 devel/schemata | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/devel/schemata b/devel/schemata
index 00ebb7a6..42b1bcf3 100644
--- a/devel/schemata
+++ b/devel/schemata
@@ -14,7 +14,7 @@ are interleaved. Keys are printed as keywords (symbols preceded by a
 colon), e.g. (:id "123" :time 54321 :from "foobar"). Null is printed as
 nil, true as t and false as nil.
 
-This is version 2 of the structured output format.
+This is version 4 of the structured output format.
 
 Version history
 ---------------
@@ -30,6 +30,10 @@ v3
 - Replaced message.filename string with a list of filenames.
 - Added part.content-disposition field.
 
+v4
+- replace signature error integer bitmask with a set of flags for
+  individual errors.
+
 Common non-terminals
 --------------------
 
@@ -121,7 +125,7 @@ sigstatus = [signature*]
 
 signature = {
     # (signature_status_to_string)
-    status:         "none"|"good"|"bad"|"error"|"unknown",
+    status:         "good"|"bad"|"error"|"unknown",
     # if status is "good":
     fingerprint?:   string,
     created?:       unix_time,
@@ -129,8 +133,20 @@ signature = {
     userid?:        string
     # if status is not "good":
     keyid?:         string
-    # if the signature has errors:
-    errors?:        int
+    errors?:    sig_errors
+}
+
+sig_errors = {
+    key-revoked?: bool,
+    key-expired?: bool,
+    sig-expired?: bool,
+    key-missing?: bool,
+    alg-unsupported?: bool,
+    crl-missing?: bool,
+    crl-too-old?: bool,
+    bad-policy?: bool,
+    sys-error?: bool,
+    tofu-conflict?: bool
 }
 
 notmuch search schema
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 03/23] cli: implement structured output version 4

In reply to this post by David Bremner-2
Since the error field is unused by the emacs front end, no changes are
needed other than bumping the format version number.

As it is, this is a bit overengineered, but it will reduce duplication
when we support gmime 3.0
---
 emacs/notmuch-query.el  |  2 +-
 notmuch-client.h        |  2 +-
 notmuch-show.c          | 54 +++++++++++++++++++++++++++++++++++++++++++++----
 test/T350-crypto.sh     |  4 ++--
 test/T355-smime.sh      |  4 ++--
 test/T450-emacs-show.sh |  2 +-
 6 files changed, 57 insertions(+), 11 deletions(-)

diff --git a/emacs/notmuch-query.el b/emacs/notmuch-query.el
index 48acb551..592fd8f1 100644
--- a/emacs/notmuch-query.el
+++ b/emacs/notmuch-query.el
@@ -30,7 +30,7 @@ A thread is a forest or list of trees. A tree is a two element
 list where the first element is a message, and the second element
 is a possibly empty forest of replies.
 "
-  (let ((args '("show" "--format=sexp" "--format-version=3")))
+  (let ((args '("show" "--format=sexp" "--format-version=4")))
     (if notmuch-show-process-crypto
  (setq args (append args '("--decrypt"))))
     (setq args (append args search-terms))
diff --git a/notmuch-client.h b/notmuch-client.h
index 62d4bcec..77b34184 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -145,7 +145,7 @@ chomp_newline (char *str)
  * this.  New (required) map fields can be added without increasing
  * this.
  */
-#define NOTMUCH_FORMAT_CUR 3
+#define NOTMUCH_FORMAT_CUR 4
 /* The minimum supported structured output format version.  Requests
  * for format versions below this will return an error. */
 #define NOTMUCH_FORMAT_MIN 1
diff --git a/notmuch-show.c b/notmuch-show.c
index accea48a..1614547b 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -340,6 +340,48 @@ signature_status_to_string (GMimeSignatureStatus x)
     return "unknown";
 }
 
+
+/* Print signature flags */
+struct key_map_struct {
+    GMimeSignatureError bit;
+    const char * string;
+};
+
+static void
+do_format_signature_errors (sprinter_t *sp, struct key_map_struct *key_map,
+    unsigned int array_map_len, GMimeSignatureError errors) {
+    sp->map_key (sp, "errors");
+    sp->begin_map (sp);
+
+    for (unsigned int i = 0; i < array_map_len; i++) {
+ if (errors & key_map[i].bit) {
+    sp->map_key (sp, key_map[i].string);
+    sp->boolean (sp, TRUE);
+ }
+    }
+
+    sp->end (sp);
+}
+
+static void
+format_signature_errors (sprinter_t *sp, GMimeSignature *signature)
+{
+    GMimeSignatureError errors = g_mime_signature_get_errors (signature);
+
+    if (errors == GMIME_SIGNATURE_ERROR_NONE)
+ return;
+
+    struct key_map_struct key_map[] = {
+ { GMIME_SIGNATURE_ERROR_EXPSIG, "sig-expired" },
+ { GMIME_SIGNATURE_ERROR_NO_PUBKEY, "key-missing"},
+ { GMIME_SIGNATURE_ERROR_EXPKEYSIG, "key-expired"},
+ { GMIME_SIGNATURE_ERROR_REVKEYSIG, "key-revoked"},
+ { GMIME_SIGNATURE_ERROR_UNSUPP_ALGO, "alg-unsupported"},
+    };
+
+    do_format_signature_errors (sp, key_map, ARRAY_SIZE(key_map), errors);
+}
+
 /* Signature status sprinter (GMime 2.6) */
 static void
 format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node)
@@ -404,10 +446,14 @@ format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node)
     }
  }
 
- GMimeSignatureError errors = g_mime_signature_get_errors (signature);
- if (errors != GMIME_SIGNATURE_ERROR_NONE) {
-    sp->map_key (sp, "errors");
-    sp->integer (sp, errors);
+ if (notmuch_format_version <= 3) {
+    GMimeSignatureError errors = g_mime_signature_get_errors (signature);
+    if (errors != GMIME_SIGNATURE_ERROR_NONE) {
+ sp->map_key (sp, "errors");
+ sp->integer (sp, errors);
+    }
+ } else {
+    format_signature_errors (sp, signature);
  }
 
  sp->end (sp);
diff --git a/test/T350-crypto.sh b/test/T350-crypto.sh
index d21cad14..0753acf3 100755
--- a/test/T350-crypto.sh
+++ b/test/T350-crypto.sh
@@ -123,7 +123,7 @@ expected='[[[{"id": "XXXXX",
  "body": [{"id": 1,
  "sigstatus": [{"status": "error",
  "keyid": "'$(echo $FINGERPRINT | cut -c 25-)'",
- "errors": 2}],
+ "errors": {"key-missing": true}}],
  "content-type": "multipart/signed",
  "content": [{"id": 2,
  "content-type": "text/plain",
@@ -367,7 +367,7 @@ expected='[[[{"id": "XXXXX",
  "body": [{"id": 1,
  "sigstatus": [{"status": "error",
  "keyid": "6D92612D94E46381",
- "errors": 8}],
+ "errors": {"key-revoked": true}}],
  "content-type": "multipart/signed",
  "content": [{"id": 2,
  "content-type": "text/plain",
diff --git a/test/T355-smime.sh b/test/T355-smime.sh
index 0f39bc69..03d24581 100755
--- a/test/T355-smime.sh
+++ b/test/T355-smime.sh
@@ -64,8 +64,8 @@ expected='[[[{"id": "XXXXX",
  "To": "[hidden email]",
  "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
  "body": [{"id": 1,
- "sigstatus": [{"status": "good",
- "fingerprint": "'$FINGERPRINT'",
+ "sigstatus": [{"fingerprint": "'$FINGERPRINT'",
+ "status": "good",
  "expires": 424242424,
  "created": 946728000}],
  "content-type": "multipart/signed",
diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh
index d302efb6..c4bc5ce0 100755
--- a/test/T450-emacs-show.sh
+++ b/test/T450-emacs-show.sh
@@ -191,7 +191,7 @@ This is an error (see *Notmuch errors* for more details)
 === ERROR ===
 [XXX]
 This is an error
-command: YYY/notmuch_fail show --format\\=sexp --format-version\\=3 --exclude\\=false \\' \\* \\'
+command: YYY/notmuch_fail show --format\\=sexp --format-version\\=4 --exclude\\=false \\' \\* \\'
 exit status: 1
 stderr:
 This is an error
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 04/23] test/multipart: reorganize creation of multipart message

In reply to this post by David Bremner-2
We want to have the bodies of the multipart available in a file on
their own for planned modifications to tests.
---
 test/T190-multipart.sh | 40 +++++++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/test/T190-multipart.sh b/test/T190-multipart.sh
index 12a10451..91a632c6 100755
--- a/test/T190-multipart.sh
+++ b/test/T190-multipart.sh
@@ -2,14 +2,7 @@
 test_description="output of multipart message"
 . ./test-lib.sh || exit 1
 
-cat <<EOF > embedded_message
-From: Carl Worth <[hidden email]>
-To: [hidden email]
-Subject: html message
-Date: Fri, 05 Jan 2001 15:42:57 +0000
-User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
-Message-ID: <[hidden email]>
-MIME-Version: 1.0
+cat <<EOF > embedded_message_body
 Content-Type: multipart/alternative; boundary="==-=-=="
 
 --==-=-==
@@ -24,15 +17,19 @@ This is an embedded message, with a multipart/alternative part.
 
 --==-=-==--
 EOF
-
-cat <<EOF > ${MAIL_DIR}/multipart
+cat <<EOF > embedded_message
 From: Carl Worth <[hidden email]>
 To: [hidden email]
-Subject: Multipart message
-Date: Fri, 05 Jan 2001 15:43:57 +0000
+Subject: html message
+Date: Fri, 05 Jan 2001 15:42:57 +0000
 User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
-Message-ID: <[hidden email]>
+Message-ID: <[hidden email]>
 MIME-Version: 1.0
+EOF
+
+cat embedded_message_body >> embedded_message
+
+cat <<EOF > multipart_body
 Content-Type: multipart/signed; boundary="==-=-=";
  micalg=pgp-sha1; protocol="application/pgp-signature"
 
@@ -44,8 +41,9 @@ Content-Type: message/rfc822
 Content-Disposition: inline
 
 EOF
-cat embedded_message >> ${MAIL_DIR}/multipart
-cat <<EOF >> ${MAIL_DIR}/multipart
+
+cat embedded_message >> multipart_body
+cat <<EOF >> multipart_body
 
 --=-=-=
 Content-Disposition: attachment; filename=attachment
@@ -73,6 +71,18 @@ W6cAmQE4dcYrx/LPLtYLZm1jsGauE5hE
 --==-=-=--
 EOF
 
+cat <<EOF > ${MAIL_DIR}/multipart
+From: Carl Worth <[hidden email]>
+To: [hidden email]
+Subject: Multipart message
+Date: Fri, 05 Jan 2001 15:43:57 +0000
+User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
+Message-ID: <[hidden email]>
+MIME-Version: 1.0
+EOF
+
+cat multipart_body >> ${MAIL_DIR}/multipart
+
 cat <<EOF > ${MAIL_DIR}/base64-part-with-crlf
 From: Carl Worth <[hidden email]>
 To: [hidden email]
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 05/23] test: mark inclusion of headers as broken in gmime-2.x

In reply to this post by David Bremner-2
The output of headers here reflects an underlying bug / quirk of
gmime-2.6.
---
 test/T190-multipart.sh | 28 ++++------------------------
 1 file changed, 4 insertions(+), 24 deletions(-)

diff --git a/test/T190-multipart.sh b/test/T190-multipart.sh
index 91a632c6..94bb0570 100755
--- a/test/T190-multipart.sh
+++ b/test/T190-multipart.sh
@@ -465,8 +465,9 @@ notmuch show --format=raw --part=0 'id:[hidden email]' >OUT
 test_expect_equal_file "${MAIL_DIR}"/multipart OUTPUT
 
 test_begin_subtest "--format=raw --part=1, message body"
+test_subtest_broken_gmime_2
 notmuch show --format=raw --part=1 'id:[hidden email]' >OUTPUT
-test_expect_equal_file "${MAIL_DIR}"/multipart OUTPUT
+test_expect_equal_file multipart_body OUTPUT
 
 test_begin_subtest "--format=raw --part=2, multipart/mixed"
 notmuch show --format=raw --part=2 'id:[hidden email]' >OUTPUT
@@ -518,30 +519,9 @@ notmuch show --format=raw --part=3 'id:[hidden email]' >OUT
 test_expect_equal_file embedded_message OUTPUT
 
 test_begin_subtest "--format=raw --part=4, rfc822's multipart"
+test_subtest_broken_gmime_2
 notmuch show --format=raw --part=4 'id:[hidden email]' >OUTPUT
-cat <<EOF >EXPECTED
-From: Carl Worth <[hidden email]>
-To: [hidden email]
-Subject: html message
-Date: Fri, 05 Jan 2001 15:42:57 +0000
-User-Agent: Notmuch/0.5 (http://notmuchmail.org) Emacs/23.3.1 (i486-pc-linux-gnu)
-Message-ID: <[hidden email]>
-MIME-Version: 1.0
-Content-Type: multipart/alternative; boundary="==-=-=="
-
---==-=-==
-Content-Type: text/html
-
-<p>This is an embedded message, with a multipart/alternative part.</p>
-
---==-=-==
-Content-Type: text/plain
-
-This is an embedded message, with a multipart/alternative part.
-
---==-=-==--
-EOF
-test_expect_equal_file EXPECTED OUTPUT
+test_expect_equal_file embedded_message_body OUTPUT
 
 test_begin_subtest "--format=raw --part=5, rfc822's html part"
 notmuch show --format=raw --part=5 'id:[hidden email]' >OUTPUT
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 06/23] test: mark test as broken in gmime 3.0

In reply to this post by David Bremner-2
Currently I'm not sure what the intent of this test is, so it's not
clear if the new answer is better or worse than the old one.
---
 test/T310-emacs.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
index 8a881941..c8a25de2 100755
--- a/test/T310-emacs.sh
+++ b/test/T310-emacs.sh
@@ -86,6 +86,7 @@ test_emacs "(let ((notmuch-show-indent-messages-width 4))
 test_expect_equal_file $EXPECTED/notmuch-show-thread-maildir-storage-with-fourfold-indentation OUTPUT
 
 test_begin_subtest "notmuch-show for message with invalid From"
+test_subtest_broken_gmime_3
 add_message "[subject]=\"message-with-invalid-from\"" \
     "[from]=\"\\\"Invalid \\\" From\\\" <[hidden email]>\""
 thread=$(notmuch search --output=threads subject:message-with-invalid-from)
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 07/23] test/crypto: mark extra space in userid as a bug in gmime-2.6

In reply to this post by David Bremner-2
I can't see the space in the output of gpg -K --with-colons
---
 test/T350-crypto.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/test/T350-crypto.sh b/test/T350-crypto.sh
index 0753acf3..720a2225 100755
--- a/test/T350-crypto.sh
+++ b/test/T350-crypto.sh
@@ -69,6 +69,7 @@ test_expect_equal_json \
     "$expected"
 
 test_begin_subtest "signature verification with full owner trust"
+test_subtest_broken_gmime_2
 # give the key full owner trust
 echo "${FINGERPRINT}:6:" | gpg --no-tty --import-ownertrust >>"$GNUPGHOME"/trust.log 2>&1
 gpg --no-tty --check-trustdb >>"$GNUPGHOME"/trust.log 2>&1
@@ -90,7 +91,7 @@ expected='[[[{"id": "XXXXX",
  "sigstatus": [{"status": "good",
  "fingerprint": "'$FINGERPRINT'",
  "created": 946728000,
- "userid": " Notmuch Test Suite <[hidden email]> (INSECURE!)"}],
+ "userid": "Notmuch Test Suite <[hidden email]> (INSECURE!)"}],
  "content-type": "multipart/signed",
  "content": [{"id": 2,
  "content-type": "text/plain",
@@ -276,6 +277,7 @@ test_expect_success \
     "(mml-secure-message-sign-encrypt)"'
 
 test_begin_subtest "decryption + signature verification"
+test_subtest_broken_gmime_2
 output=$(notmuch show --format=json --decrypt subject:"test encrypted message 002" \
     | notmuch_json_show_sanitize \
     | sed -e 's|"created": [1234567890]*|"created": 946728000|')
@@ -295,7 +297,7 @@ expected='[[[{"id": "XXXXX",
  "sigstatus": [{"status": "good",
  "fingerprint": "'$FINGERPRINT'",
  "created": 946728000,
- "userid": " Notmuch Test Suite <[hidden email]> (INSECURE!)"}],
+ "userid": "Notmuch Test Suite <[hidden email]> (INSECURE!)"}],
  "content-type": "multipart/encrypted",
  "content": [{"id": 2,
  "content-type": "application/pgp-encrypted",
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 08/23] test: add test for modified pgp/mime signed message

In reply to this post by David Bremner-2
This is a good thing to test in any case, but particularly as we hit
the dark corners of the gmime crypto API.
---
 test/T350-crypto.sh | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/test/T350-crypto.sh b/test/T350-crypto.sh
index 720a2225..4a2c4c85 100755
--- a/test/T350-crypto.sh
+++ b/test/T350-crypto.sh
@@ -68,6 +68,45 @@ test_expect_equal_json \
     "$output" \
     "$expected"
 
+test_begin_subtest "detection of modified signed contents"
+emacs_fcc_message \
+    "bad signed message 001" \
+    "Incriminating stuff. This is a test signed message." \
+    "(mml-secure-message-sign)"
+
+file=$(notmuch search --output=files subject:"bad signed message 001")
+
+sed -i 's/Incriminating stuff. //' ${file}
+
+output=$(notmuch show --format=json --verify subject:"bad signed message 001" \
+    | notmuch_json_show_sanitize \
+    | sed -e 's|"created": [1234567890]*|"created": 946728000|')
+expected='[[[{"id": "XXXXX",
+ "match": true,
+ "excluded": false,
+ "filename": ["YYYYY"],
+ "timestamp": 946728000,
+ "date_relative": "2000-01-01",
+ "tags": ["inbox","signed"],
+ "headers": {"Subject": "bad signed message 001",
+ "From": "Notmuch Test Suite <[hidden email]>",
+ "To": "[hidden email]",
+ "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
+ "body": [{"id": 1,
+ "sigstatus": [{"status": "bad",
+ "keyid": "'$(echo $FINGERPRINT | cut -c 25-)'"}],
+ "content-type": "multipart/signed",
+ "content": [{"id": 2,
+ "content-type": "text/plain",
+ "content": "This is a test signed message.\n"},
+ {"id": 3,
+ "content-type": "application/pgp-signature",
+ "content-length": "NONZERO"}]}]},
+ []]]]'
+test_expect_equal_json \
+    "$output" \
+    "$expected"
+
 test_begin_subtest "signature verification with full owner trust"
 test_subtest_broken_gmime_2
 # give the key full owner trust
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 09/23] test/crypto: add test for corrupted signatures

In reply to this post by David Bremner-2
Have an empty list of signatures is not the nicest mechanism to signal
complete failure to verify, but it's the one we currently have.
---
 test/T350-crypto.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/test/T350-crypto.sh b/test/T350-crypto.sh
index 4a2c4c85..7dab39a2 100755
--- a/test/T350-crypto.sh
+++ b/test/T350-crypto.sh
@@ -107,6 +107,49 @@ test_expect_equal_json \
     "$output" \
     "$expected"
 
+test_begin_subtest "corrupted pgp/mime signature"
+emacs_fcc_message \
+    "bad signed message 002" \
+    "Incriminating stuff. This is a test signed message." \
+    "(mml-secure-message-sign)"
+
+file=$(notmuch search --output=files subject:"bad signed message 002")
+
+awk '/-----BEGIN PGP SIGNATURE-----/{flag=1;print;next} \
+     /-----END PGP SIGNATURE-----/{flag=0;print;next} \
+     flag{gsub(/[A-Za-z]/,"0");print}!flag{print}' $file > $file.new
+
+rm $file
+mv $file.new $file
+
+output=$(notmuch show --format=json --verify subject:"bad signed message 002" \
+    | notmuch_json_show_sanitize \
+    | sed -e 's|"created": [1234567890]*|"created": 946728000|')
+expected='[[[{"id": "XXXXX",
+ "match": true,
+ "excluded": false,
+ "filename": ["YYYYY"],
+ "timestamp": 946728000,
+ "date_relative": "2000-01-01",
+ "tags": ["inbox","signed"],
+ "headers": {"Subject": "bad signed message 002",
+ "From": "Notmuch Test Suite <[hidden email]>",
+ "To": "[hidden email]",
+ "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
+ "body": [{"id": 1,
+ "sigstatus": [],
+ "content-type": "multipart/signed",
+ "content": [{"id": 2,
+ "content-type": "text/plain",
+ "content": "Incriminating stuff. This is a test signed message.\n"},
+ {"id": 3,
+ "content-type": "application/pgp-signature",
+ "content-length": "NONZERO"}]}]},
+ []]]]'
+test_expect_equal_json \
+    "$output" \
+    "$expected"
+
 test_begin_subtest "signature verification with full owner trust"
 test_subtest_broken_gmime_2
 # give the key full owner trust
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 10/23] test: test parsing of malformed from addresses

In reply to this post by David Bremner-2
This was previously tested in T200-thread-naming.sh, but failures due
to changes in address parsing were confusing because they had nothing
to do with threads.
---
 test/T050-new.sh | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/test/T050-new.sh b/test/T050-new.sh
index ffa303ef..66235306 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -140,6 +140,13 @@ ln -s "$external_msg_filename" "$gen_msg_filename"
 output=$(NOTMUCH_NEW --debug)
 test_expect_equal "$output" "Added 1 new message to the database."
 
+test_begin_subtest "Index malformed from address."
+test_subtest_broken_gmime_3
+add_message '[subject]="test subject"' \
+            '[date]="Sat, 13 Jan 2001 15:43:45 -0000"' \
+            '[from]="Malformed From \<[hidden email]\>"'
+output=$(notmuch search --sort=newest-first from:[hidden email] | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2001-01-13 [1/1] Malformed From; test subject (inbox unread)"
 
 test_begin_subtest "Broken symlink aborts"
 ln -s does-not-exist "${MAIL_DIR}/broken"
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 11/23] cli: replace use of g_mime_message_get_date_as_string

In reply to this post by David Bremner-2
This function goes away in gmime-3.0. Also, the memory management is
apparently error prone, witness the memory leak in notmuch-reply.
---
 notmuch-reply.c    |  2 +-
 notmuch-show.c     |  8 ++------
 util/gmime-extra.c | 35 +++++++++++++++++++++++++++++++++++
 util/gmime-extra.h |  8 ++++++++
 4 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index b88f1d31..65753c18 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -61,7 +61,7 @@ format_part_reply (GMimeStream *stream, mime_node_t *node)
   recipients_string);
  g_free (recipients_string);
  g_mime_stream_printf (stream, "> Subject: %s\n", g_mime_message_get_subject (message));
- g_mime_stream_printf (stream, "> Date: %s\n", g_mime_message_get_date_as_string (message));
+ g_mime_stream_printf (stream, "> Date: %s\n", g_mime_message_get_date_string (node, message));
  g_mime_stream_printf (stream, ">\n");
     } else if (GMIME_IS_PART (node->part)) {
  GMimeContentType *content_type = g_mime_object_get_content_type (node->part);
diff --git a/notmuch-show.c b/notmuch-show.c
index 1614547b..62275923 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -204,7 +204,6 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
     InternetAddressList *recipients;
     char *recipients_string;
     const char *reply_to_string;
-    char *date_string;
 
     sp->begin_map (sp);
 
@@ -252,9 +251,7 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
  sp->string (sp, g_mime_object_get_header (GMIME_OBJECT (message), "References"));
     } else {
  sp->map_key (sp, "Date");
- date_string = g_mime_message_get_date_as_string (message);
- sp->string (sp, date_string);
- g_free (date_string);
+ sp->string (sp, g_mime_message_get_date_string (sp, message));
     }
 
     sp->end (sp);
@@ -532,9 +529,8 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,
  if (recipients_string)
     g_mime_stream_printf (stream, "Cc: %s\n", recipients_string);
  g_free (recipients_string);
- date_string = g_mime_message_get_date_as_string (message);
+ date_string = g_mime_message_get_date_string (node, message);
  g_mime_stream_printf (stream, "Date: %s\n", date_string);
- g_free (date_string);
  g_mime_stream_printf (stream, "\fheader}\n");
 
  g_mime_stream_printf (stream, "\fbody{\n");
diff --git a/util/gmime-extra.c b/util/gmime-extra.c
index f1538587..01fe9e35 100644
--- a/util/gmime-extra.c
+++ b/util/gmime-extra.c
@@ -18,3 +18,38 @@ g_mime_stream_stdout_new()
 
     return stream_buffered;
 }
+
+/**
+ * copy a glib string into a talloc context, and free it.
+ */
+static char*
+g_string_talloc_strdup (void *ctx, char *g_string)
+{
+    char *new_str = talloc_strdup (ctx, g_string);
+    g_free (g_string);
+    return new_str;
+}
+
+#if (GMIME_MAJOR_VERSION < 3)
+
+char *
+g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
+{
+    char *date = g_mime_message_get_date_as_string (message);
+    return g_string_talloc_strdup (ctx, date);
+}
+
+#else /* GMime >= 3.0 */
+
+char *
+g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
+{
+    GDateTime* parsed_date = g_mime_message_get_date (message);
+    if (parsed_date) {
+ char *date = g_mime_utils_header_format_date (parsed_date);
+ return g_string_talloc_strdup (ctx, date);
+    } else {
+ return talloc_strdup(ctx, "Thu, 01 Jan 1970 00:00:00 +0000");
+    }
+}
+#endif
diff --git a/util/gmime-extra.h b/util/gmime-extra.h
index e0432a94..6e2f6ca5 100644
--- a/util/gmime-extra.h
+++ b/util/gmime-extra.h
@@ -3,4 +3,12 @@
 #include <gmime/gmime.h>
 
 GMimeStream *g_mime_stream_stdout_new(void);
+
+#include <talloc.h>
+
+/**
+ * return talloc allocated date string
+ */
+char *g_mime_message_get_date_string (void *ctx, GMimeMessage *message);
+
 #endif
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 12/23] cli: replace use of g_mime_message_get_reply_to

In reply to this post by David Bremner-2
This function changes signature in gmime 3.0, so we provide two new
functions, one for each signature.
---
 notmuch-reply.c    | 10 ++++------
 notmuch-show.c     |  4 +++-
 util/gmime-extra.c | 37 +++++++++++++++++++++++++++++++++++++
 util/gmime-extra.h | 12 ++++++++++++
 4 files changed, 56 insertions(+), 7 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 65753c18..12439284 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -268,12 +268,11 @@ reply_to_header_is_redundant (GMimeMessage *message,
 
 static InternetAddressList *get_sender(GMimeMessage *message)
 {
-    const char *reply_to;
-
-    reply_to = g_mime_message_get_reply_to (message);
-    if (reply_to && *reply_to) {
- InternetAddressList *reply_to_list;
+    InternetAddressList *reply_to_list;
 
+    reply_to_list = g_mime_message_get_reply_to_list (message);
+    if (reply_to_list &&
+ internet_address_list_length (reply_to_list) > 0) {
         /*
  * Some mailing lists munge the Reply-To header despite it
  * being A Bad Thing, see
@@ -287,7 +286,6 @@ static InternetAddressList *get_sender(GMimeMessage *message)
  * to the list. Note that the address in the Reply-To header
  * will always appear in the reply if reply_all is true.
  */
- reply_to_list = internet_address_list_parse_string (reply_to);
  if (! reply_to_header_is_redundant (message, reply_to_list))
     return reply_to_list;
 
diff --git a/notmuch-show.c b/notmuch-show.c
index 62275923..b4339abe 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -204,6 +204,7 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
     InternetAddressList *recipients;
     char *recipients_string;
     const char *reply_to_string;
+    void *local = talloc_new (sp);
 
     sp->begin_map (sp);
 
@@ -237,7 +238,7 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
  g_free (recipients_string);
     }
 
-    reply_to_string = g_mime_message_get_reply_to (message);
+    reply_to_string = g_mime_message_get_reply_to_string (local, message);
     if (reply_to_string) {
  sp->map_key (sp, "Reply-To");
  sp->string (sp, reply_to_string);
@@ -255,6 +256,7 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
     }
 
     sp->end (sp);
+    talloc_free (local);
 }
 
 /* Write a MIME text part out to the given stream.
diff --git a/util/gmime-extra.c b/util/gmime-extra.c
index 01fe9e35..33751de7 100644
--- a/util/gmime-extra.c
+++ b/util/gmime-extra.c
@@ -39,6 +39,28 @@ g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
     return g_string_talloc_strdup (ctx, date);
 }
 
+InternetAddressList *
+g_mime_message_get_reply_to_list (GMimeMessage *message)
+{
+    const char *reply_to;
+
+    reply_to = g_mime_message_get_reply_to (message);
+    if (reply_to && *reply_to)
+ return internet_address_list_parse_string (reply_to);
+    else
+ return NULL;
+}
+
+/**
+ * return talloc allocated reply-to string
+ */
+char *
+g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message)
+{
+    return talloc_strdup(ctx, g_mime_message_get_reply_to (message));
+}
+
+
 #else /* GMime >= 3.0 */
 
 char *
@@ -52,4 +74,19 @@ g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
  return talloc_strdup(ctx, "Thu, 01 Jan 1970 00:00:00 +0000");
     }
 }
+
+InternetAddressList *
+g_mime_message_get_reply_to_list(GMimeMessage *message)
+{
+    return g_mime_message_get_reply_to (message);
+}
+
+char *
+g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message)
+{
+    InternetAddressList *list = g_mime_message_get_reply_to (message);
+    return g_string_talloc_strdup (ctx, internet_address_list_to_string (list, NULL, 0));
+}
+
+
 #endif
diff --git a/util/gmime-extra.h b/util/gmime-extra.h
index 6e2f6ca5..794ffbfd 100644
--- a/util/gmime-extra.h
+++ b/util/gmime-extra.h
@@ -10,5 +10,17 @@ GMimeStream *g_mime_stream_stdout_new(void);
  * return talloc allocated date string
  */
 char *g_mime_message_get_date_string (void *ctx, GMimeMessage *message);
+InternetAddressList * g_mime_message_get_reply_to_list (GMimeMessage *message);
+
+/**
+ * return talloc allocated reply-to string
+ */
+char * g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message);
+
+
+/**
+ * Return glib allocated reply-to list
+ */
+InternetAddressList * g_mime_message_get_reply_to_list (GMimeMessage *message);
 
 #endif
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 13/23] lib/cli: replace use of g_mime_message_get_sender

In reply to this post by David Bremner-2
This function changes semantics in gmime-3.0 so make a new function
that provides the same functionality in both
---
 lib/index.cc          |  6 ++----
 lib/notmuch-private.h |  2 +-
 notmuch-reply.c       |  5 ++---
 notmuch-show.c        |  4 ++--
 util/gmime-extra.c    | 17 +++++++++++++++++
 util/gmime-extra.h    | 17 +++++++++++++----
 6 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/lib/index.cc b/lib/index.cc
index 8c145540..d2472896 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -439,7 +439,7 @@ _notmuch_message_index_file (notmuch_message_t *message,
 {
     GMimeMessage *mime_message;
     InternetAddressList *addresses;
-    const char *from, *subject;
+    const char *subject;
     notmuch_status_t status;
 
     status = _notmuch_message_file_get_mime_message (message_file,
@@ -447,9 +447,7 @@ _notmuch_message_index_file (notmuch_message_t *message,
     if (status)
  return status;
 
-    from = g_mime_message_get_sender (mime_message);
-
-    addresses = internet_address_list_parse_string (from);
+    addresses = g_mime_message_get_from (mime_message);
     if (addresses) {
  _index_address_list (message, "from", addresses);
  g_object_unref (addresses);
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index ac315e4c..5dfebf5d 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -46,7 +46,7 @@ NOTMUCH_BEGIN_DECLS
 
 #include <talloc.h>
 
-#include <gmime/gmime.h>
+#include "gmime-extra.h"
 
 #include "xutil.h"
 #include "error_util.h"
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 12439284..29a5ab6c 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -47,9 +47,9 @@ format_part_reply (GMimeStream *stream, mime_node_t *node)
  InternetAddressList *recipients;
  char *recipients_string;
 
- g_mime_stream_printf (stream, "> From: %s\n", g_mime_message_get_sender (message));
  recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
  recipients_string = internet_address_list_to_string (recipients, 0);
+ g_mime_stream_printf (stream, "> From: %s\n", g_mime_message_get_from_string (message));
  if (recipients_string)
     g_mime_stream_printf (stream, "> To: %s\n",
   recipients_string);
@@ -292,8 +292,7 @@ static InternetAddressList *get_sender(GMimeMessage *message)
  g_object_unref (G_OBJECT (reply_to_list));
     }
 
-    return internet_address_list_parse_string (
- g_mime_message_get_sender (message));
+    return g_mime_message_get_from (message);
 }
 
 static InternetAddressList *get_to(GMimeMessage *message)
diff --git a/notmuch-show.c b/notmuch-show.c
index b4339abe..edc0537c 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -212,7 +212,7 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
     sp->string (sp, g_mime_message_get_subject (message));
 
     sp->map_key (sp, "From");
-    sp->string (sp, g_mime_message_get_sender (message));
+    sp->string (sp, g_mime_message_get_from_string (message));
 
     recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
     recipients_string = internet_address_list_to_string (recipients, 0);
@@ -520,9 +520,9 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,
  if (node->envelope_file)
     g_mime_stream_printf (stream, "%s\n", _get_one_line_summary (ctx, node->envelope_file));
  g_mime_stream_printf (stream, "Subject: %s\n", g_mime_message_get_subject (message));
- g_mime_stream_printf (stream, "From: %s\n", g_mime_message_get_sender (message));
  recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
  recipients_string = internet_address_list_to_string (recipients, 0);
+ g_mime_stream_printf (stream, "From: %s\n", g_mime_message_get_from_string (message));
  if (recipients_string)
     g_mime_stream_printf (stream, "To: %s\n", recipients_string);
  g_free (recipients_string);
diff --git a/util/gmime-extra.c b/util/gmime-extra.c
index 33751de7..8590c55d 100644
--- a/util/gmime-extra.c
+++ b/util/gmime-extra.c
@@ -40,6 +40,17 @@ g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
 }
 
 InternetAddressList *
+g_mime_message_get_from (GMimeMessage *message)
+{
+    return internet_address_list_parse_string (g_mime_message_get_sender (message));
+}
+
+const char *
+g_mime_message_get_from_string (GMimeMessage *message) {
+    return  g_mime_message_get_sender (message);
+}
+
+InternetAddressList *
 g_mime_message_get_reply_to_list (GMimeMessage *message)
 {
     const char *reply_to;
@@ -81,6 +92,12 @@ g_mime_message_get_reply_to_list(GMimeMessage *message)
     return g_mime_message_get_reply_to (message);
 }
 
+const char *
+g_mime_message_get_from_string (GMimeMessage *message)
+{
+    return g_mime_object_get_header (GMIME_OBJECT (message), "From");
+}
+
 char *
 g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message)
 {
diff --git a/util/gmime-extra.h b/util/gmime-extra.h
index 794ffbfd..04d63026 100644
--- a/util/gmime-extra.h
+++ b/util/gmime-extra.h
@@ -9,18 +9,27 @@ GMimeStream *g_mime_stream_stdout_new(void);
 /**
  * return talloc allocated date string
  */
+
 char *g_mime_message_get_date_string (void *ctx, GMimeMessage *message);
-InternetAddressList * g_mime_message_get_reply_to_list (GMimeMessage *message);
 
 /**
- * return talloc allocated reply-to string
+ * glib allocated list of From: addresses
  */
-char * g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message);
 
+InternetAddressList * g_mime_message_get_from (GMimeMessage *message);
 
 /**
- * Return glib allocated reply-to list
+ * return string for From: address
+ * (owned by gmime)
  */
+const char * g_mime_message_get_from_string (GMimeMessage *message);
+
 InternetAddressList * g_mime_message_get_reply_to_list (GMimeMessage *message);
 
+/**
+ * return talloc allocated reply-to string
+ */
+char * g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message);
+
+
 #endif
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 14/23] cli: replace use of g_mime_message_get_recipients

In reply to this post by David Bremner-2
This function, and associated enum, have been renamed and generalized
in gmime-3.0.
---
 notmuch-reply.c    | 21 +++++++++------------
 notmuch-show.c     | 17 +++++------------
 util/gmime-extra.c | 20 ++++++++++++++++++++
 util/gmime-extra.h | 22 ++++++++++++++++++++--
 4 files changed, 54 insertions(+), 26 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 29a5ab6c..f9e8431f 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -44,18 +44,15 @@ format_part_reply (GMimeStream *stream, mime_node_t *node)
       notmuch_message_get_header (node->envelope_file, "from"));
     } else if (GMIME_IS_MESSAGE (node->part)) {
  GMimeMessage *message = GMIME_MESSAGE (node->part);
- InternetAddressList *recipients;
  char *recipients_string;
 
- recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
- recipients_string = internet_address_list_to_string (recipients, 0);
  g_mime_stream_printf (stream, "> From: %s\n", g_mime_message_get_from_string (message));
+ recipients_string = g_mime_message_get_address_string (message, GMIME_ADDRESS_TYPE_TO);
  if (recipients_string)
     g_mime_stream_printf (stream, "> To: %s\n",
   recipients_string);
  g_free (recipients_string);
- recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_CC);
- recipients_string = internet_address_list_to_string (recipients, 0);
+ recipients_string = g_mime_message_get_address_string (message, GMIME_ADDRESS_TYPE_CC);
  if (recipients_string)
     g_mime_stream_printf (stream, "> Cc: %s\n",
   recipients_string);
@@ -297,17 +294,17 @@ static InternetAddressList *get_sender(GMimeMessage *message)
 
 static InternetAddressList *get_to(GMimeMessage *message)
 {
-    return g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
+    return g_mime_message_get_addresses (message, GMIME_ADDRESS_TYPE_TO);
 }
 
 static InternetAddressList *get_cc(GMimeMessage *message)
 {
-    return g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_CC);
+    return g_mime_message_get_addresses (message, GMIME_ADDRESS_TYPE_CC);
 }
 
 static InternetAddressList *get_bcc(GMimeMessage *message)
 {
-    return g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_BCC);
+    return g_mime_message_get_addresses (message, GMIME_ADDRESS_TYPE_BCC);
 }
 
 /* Augment the recipients of 'reply' from the "Reply-to:", "From:",
@@ -338,10 +335,10 @@ add_recipients_from_message (GMimeMessage *reply,
  InternetAddressList * (*get_header)(GMimeMessage *message);
  GMimeRecipientType recipient_type;
     } reply_to_map[] = {
- { get_sender, GMIME_RECIPIENT_TYPE_TO },
- { get_to, GMIME_RECIPIENT_TYPE_TO },
- { get_cc, GMIME_RECIPIENT_TYPE_CC },
- { get_bcc, GMIME_RECIPIENT_TYPE_BCC },
+ { get_sender, GMIME_ADDRESS_TYPE_TO },
+ { get_to, GMIME_ADDRESS_TYPE_TO },
+ { get_cc, GMIME_ADDRESS_TYPE_CC },
+ { get_bcc, GMIME_ADDRESS_TYPE_BCC },
     };
     const char *from_addr = NULL;
     unsigned int i;
diff --git a/notmuch-show.c b/notmuch-show.c
index edc0537c..8afc5273 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -201,7 +201,6 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
     /* Any changes to the JSON or S-Expression format should be
      * reflected in the file devel/schemata. */
 
-    InternetAddressList *recipients;
     char *recipients_string;
     const char *reply_to_string;
     void *local = talloc_new (sp);
@@ -214,24 +213,21 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
     sp->map_key (sp, "From");
     sp->string (sp, g_mime_message_get_from_string (message));
 
-    recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
-    recipients_string = internet_address_list_to_string (recipients, 0);
+    recipients_string = g_mime_message_get_address_string (message, GMIME_ADDRESS_TYPE_TO);
     if (recipients_string) {
  sp->map_key (sp, "To");
  sp->string (sp, recipients_string);
  g_free (recipients_string);
     }
 
-    recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_CC);
-    recipients_string = internet_address_list_to_string (recipients, 0);
+    recipients_string = g_mime_message_get_address_string (message, GMIME_ADDRESS_TYPE_CC);
     if (recipients_string) {
  sp->map_key (sp, "Cc");
  sp->string (sp, recipients_string);
  g_free (recipients_string);
     }
 
-    recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_BCC);
-    recipients_string = internet_address_list_to_string (recipients, 0);
+    recipients_string = g_mime_message_get_address_string (message, GMIME_ADDRESS_TYPE_BCC);
     if (recipients_string) {
  sp->map_key (sp, "Bcc");
  sp->string (sp, recipients_string);
@@ -512,7 +508,6 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,
 
     if (GMIME_IS_MESSAGE (node->part)) {
  GMimeMessage *message = GMIME_MESSAGE (node->part);
- InternetAddressList *recipients;
  char *recipients_string;
  char *date_string;
 
@@ -520,14 +515,12 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node,
  if (node->envelope_file)
     g_mime_stream_printf (stream, "%s\n", _get_one_line_summary (ctx, node->envelope_file));
  g_mime_stream_printf (stream, "Subject: %s\n", g_mime_message_get_subject (message));
- recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_TO);
- recipients_string = internet_address_list_to_string (recipients, 0);
  g_mime_stream_printf (stream, "From: %s\n", g_mime_message_get_from_string (message));
+ recipients_string = g_mime_message_get_address_string (message, GMIME_ADDRESS_TYPE_TO);
  if (recipients_string)
     g_mime_stream_printf (stream, "To: %s\n", recipients_string);
  g_free (recipients_string);
- recipients = g_mime_message_get_recipients (message, GMIME_RECIPIENT_TYPE_CC);
- recipients_string = internet_address_list_to_string (recipients, 0);
+ recipients_string = g_mime_message_get_address_string (message, GMIME_ADDRESS_TYPE_CC);
  if (recipients_string)
     g_mime_stream_printf (stream, "Cc: %s\n", recipients_string);
  g_free (recipients_string);
diff --git a/util/gmime-extra.c b/util/gmime-extra.c
index 8590c55d..8f9e77a1 100644
--- a/util/gmime-extra.c
+++ b/util/gmime-extra.c
@@ -33,6 +33,19 @@ g_string_talloc_strdup (void *ctx, char *g_string)
 #if (GMIME_MAJOR_VERSION < 3)
 
 char *
+g_mime_message_get_address_string (GMimeMessage *message, GMimeRecipientType type)
+{
+    InternetAddressList *list = g_mime_message_get_recipients (message, type);
+    return internet_address_list_to_string (list, 0);
+}
+
+inline InternetAddressList *
+g_mime_message_get_addresses (GMimeMessage *message, GMimeRecipientType type)
+{
+    return g_mime_message_get_recipients (message, type);
+}
+
+char *
 g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
 {
     char *date = g_mime_message_get_date_as_string (message);
@@ -75,6 +88,13 @@ g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message)
 #else /* GMime >= 3.0 */
 
 char *
+g_mime_message_get_address_string (GMimeMessage *message, GMimeAddressType type)
+{
+    InternetAddressList *list = g_mime_message_get_addresses (message, type);
+    return internet_address_list_to_string (list, NULL, 0);
+}
+
+char *
 g_mime_message_get_date_string (void *ctx, GMimeMessage *message)
 {
     GDateTime* parsed_date = g_mime_message_get_date (message);
diff --git a/util/gmime-extra.h b/util/gmime-extra.h
index 04d63026..fef4f425 100644
--- a/util/gmime-extra.h
+++ b/util/gmime-extra.h
@@ -6,6 +6,26 @@ GMimeStream *g_mime_stream_stdout_new(void);
 
 #include <talloc.h>
 
+
+#if (GMIME_MAJOR_VERSION < 3)
+
+#define GMIME_ADDRESS_TYPE_TO GMIME_RECIPIENT_TYPE_TO
+#define GMIME_ADDRESS_TYPE_CC GMIME_RECIPIENT_TYPE_CC
+#define GMIME_ADDRESS_TYPE_BCC GMIME_RECIPIENT_TYPE_BCC
+
+
+#else /* GMime >= 3.0 */
+typedef GMimeAddressType GMimeRecipientType;
+#endif
+
+/**
+ * Return the contents of the appropriate address header as a string
+ * Should be freed using g_free
+ */
+char *g_mime_message_get_address_string (GMimeMessage *message, GMimeRecipientType type);
+
+InternetAddressList * g_mime_message_get_addresses (GMimeMessage *message, GMimeRecipientType type);
+
 /**
  * return talloc allocated date string
  */
@@ -30,6 +50,4 @@ InternetAddressList * g_mime_message_get_reply_to_list (GMimeMessage *message);
  * return talloc allocated reply-to string
  */
 char * g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message);
-
-
 #endif
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 15/23] util: fake gmime-2.6 compatible API for gmime-3.0

In reply to this post by David Bremner-2
Several functions have added arguments which accept NULL and provide
hopefully sensible defaults. Use macros to minimize source changes.
---
 util/gmime-extra.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/util/gmime-extra.h b/util/gmime-extra.h
index fef4f425..3c16e46e 100644
--- a/util/gmime-extra.h
+++ b/util/gmime-extra.h
@@ -16,6 +16,29 @@ GMimeStream *g_mime_stream_stdout_new(void);
 
 #else /* GMime >= 3.0 */
 typedef GMimeAddressType GMimeRecipientType;
+
+#define GMIME_ENABLE_RFC_2047_WORKAROUNDS 0xdeadbeef
+#define g_mime_content_type_to_string(c) g_mime_content_type_get_mime_type (c)
+#define g_mime_filter_crlf_new(encode,dots) g_mime_filter_dos2unix_new (FALSE)
+#define g_mime_gpg_context_new(func,path) g_mime_gpg_context_new ()
+#define g_mime_gpg_context_set_use_agent(ctx,val) /*ignore*/
+#define g_mime_gpg_context_set_always_trust(ctx,val) /*ignore*/
+#define g_mime_init(flags) g_mime_init()
+#define g_mime_message_add_recipient(m,t,n,a) g_mime_message_add_mailbox (m,t,n,a)
+#define g_mime_message_set_subject(m,s) g_mime_message_set_subject(m,s,NULL)
+#define g_mime_multipart_encrypted_decrypt(mpe,ctx,out,err) g_mime_multipart_encrypted_decrypt(mpe, 0, NULL, out, err)
+#define g_mime_multipart_signed_verify(mps,ctx,err) g_mime_multipart_signed_verify(mps, 0, err)
+#define g_mime_object_write_to_stream(o,s) g_mime_object_write_to_stream (o,NULL,s)
+#define g_mime_object_set_header(o,h,v) g_mime_object_set_header (o,h,v,NULL)
+#define g_mime_parser_construct_message(p) g_mime_parser_construct_message (p, g_mime_parser_options_get_default ())
+#define g_mime_part_get_content_object(p) g_mime_part_get_content (p)
+#define g_mime_pkcs7_context_new(arg) g_mime_pkcs7_context_new()
+#define g_mime_pkcs7_context_set_always_trust(ctx,val) /*ignore*/
+#define g_mime_signature_get_errors(sig) g_mime_signature_get_status (sig)
+#define g_mime_utils_header_decode_text(txt) g_mime_utils_header_decode_text (NULL, txt)
+#define internet_address_to_string(ia,encode) internet_address_to_string (ia,NULL,encode)
+#define internet_address_list_parse_string(str) internet_address_list_parse (NULL,str)
+typedef GMimeAddressType GMimeRecipientType;
 #endif
 
 /**
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 16/23] cli: generalize use of GMIME_SIGNATURE_{ERROR, STATUS} to gmime-3

In reply to this post by David Bremner-2
The ERROR enum is merged into to the STATUS enum, and the set of flags
is different.
---
 notmuch-show.c     | 49 ++++++++++++++++++++++++++++++++++++++-----------
 util/gmime-extra.c | 41 +++++++++++++++++++++++++++++++++++++++++
 util/gmime-extra.h | 13 ++++++++++++-
 3 files changed, 91 insertions(+), 12 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 8afc5273..3234ab95 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -320,22 +320,21 @@ show_text_part_content (GMimeObject *part, GMimeStream *stream_out,
  g_object_unref(stream_filter);
 }
 
-/* Get signature status string (GMime 2.6) */
 static const char*
-signature_status_to_string (GMimeSignatureStatus x)
+signature_status_to_string (GMimeSignatureStatus status)
 {
-    switch (x) {
-    case GMIME_SIGNATURE_STATUS_GOOD:
- return "good";
-    case GMIME_SIGNATURE_STATUS_BAD:
+    if (g_mime_signature_status_bad (status))
  return "bad";
-    case GMIME_SIGNATURE_STATUS_ERROR:
+
+    if (g_mime_signature_status_error (status))
  return "error";
-    }
+
+    if (g_mime_signature_status_good (status))
+ return "good";
+
     return "unknown";
 }
 
-
 /* Print signature flags */
 struct key_map_struct {
     GMimeSignatureError bit;
@@ -358,6 +357,7 @@ do_format_signature_errors (sprinter_t *sp, struct key_map_struct *key_map,
     sp->end (sp);
 }
 
+#if (GMIME_MAJOR_VERSION < 3)
 static void
 format_signature_errors (sprinter_t *sp, GMimeSignature *signature)
 {
@@ -376,6 +376,33 @@ format_signature_errors (sprinter_t *sp, GMimeSignature *signature)
 
     do_format_signature_errors (sp, key_map, ARRAY_SIZE(key_map), errors);
 }
+#else
+static void
+format_signature_errors (sprinter_t *sp, GMimeSignature *signature)
+{
+    GMimeSignatureError errors = g_mime_signature_get_errors (signature);
+
+    if (!(errors & GMIME_SIGNATURE_STATUS_ERROR_MASK))
+ return;
+
+    struct {
+ GMimeSignatureStatus bit;
+ const char * string;
+    } key_map[] = {
+ { GMIME_SIGNATURE_STATUS_KEY_REVOKED, "key-revoked"},
+ { GMIME_SIGNATURE_STATUS_KEY_EXPIRED, "key-expired"},
+ { GMIME_SIGNATURE_STATUS_SIG_EXPIRED, "sig-expired" },
+ { GMIME_SIGNATURE_STATUS_KEY_MISSING, "key-missing"},
+ { GMIME_SIGNATURE_STATUS_CRL_MISSING, "crl-missing"},
+ { GMIME_SIGNATURE_STATUS_CRL_TOO_OLD, "crl-too-old"},
+ { GMIME_SIGNATURE_STATUS_BAD_POLICY, "bad-policy"},
+ { GMIME_SIGNATURE_STATUS_SYS_ERROR, "sys-error"},
+ { GMIME_SIGNATURE_STATUS_TOFU_CONFLICT, "tofu-conflict"},
+    };
+
+    do_format_signature_errors (sp, key_map, ARRAY_SIZE(key_map), errors);
+}
+#endif
 
 /* Signature status sprinter (GMime 2.6) */
 static void
@@ -405,7 +432,7 @@ format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node)
  sp->string (sp, signature_status_to_string (status));
 
  GMimeCertificate *certificate = g_mime_signature_get_certificate (signature);
- if (status == GMIME_SIGNATURE_STATUS_GOOD) {
+ if (g_mime_signature_status_good (status)) {
     if (certificate) {
  sp->map_key (sp, "fingerprint");
  sp->string (sp, g_mime_certificate_get_fingerprint (certificate));
@@ -443,7 +470,7 @@ format_part_sigstatus_sprinter (sprinter_t *sp, mime_node_t *node)
 
  if (notmuch_format_version <= 3) {
     GMimeSignatureError errors = g_mime_signature_get_errors (signature);
-    if (errors != GMIME_SIGNATURE_ERROR_NONE) {
+    if (g_mime_signature_status_error (errors)) {
  sp->map_key (sp, "errors");
  sp->integer (sp, errors);
     }
diff --git a/util/gmime-extra.c b/util/gmime-extra.c
index 8f9e77a1..350f75ea 100644
--- a/util/gmime-extra.c
+++ b/util/gmime-extra.c
@@ -84,6 +84,20 @@ g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message)
     return talloc_strdup(ctx, g_mime_message_get_reply_to (message));
 }
 
+gboolean
+g_mime_signature_status_good (GMimeSignatureStatus status) {
+    return (status == GMIME_SIGNATURE_STATUS_GOOD);
+}
+
+gboolean
+g_mime_signature_status_bad (GMimeSignatureStatus status) {
+    return (status == GMIME_SIGNATURE_STATUS_BAD);
+}
+
+gboolean
+g_mime_signature_status_error (GMimeSignatureError error) {
+    return (error != GMIME_SIGNATURE_ERROR_NONE);
+}
 
 #else /* GMime >= 3.0 */
 
@@ -125,5 +139,32 @@ g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message)
     return g_string_talloc_strdup (ctx, internet_address_list_to_string (list, NULL, 0));
 }
 
+void
+g_mime_parser_set_scan_from (GMimeParser *parser, gboolean flag)
+{
+    g_mime_parser_set_format (parser, flag ? GMIME_FORMAT_MBOX : GMIME_FORMAT_MESSAGE);
+}
+
+/* In GMime 3.0, status GOOD and VALID both imply something about the
+ * validity of the UIDs attached to the signing key. This forces us to
+ * use following somewhat relaxed definition of a "good" signature to
+ * preserve current notmuch semantics.
+ */
+
+gboolean
+g_mime_signature_status_good (GMimeSignatureStatus status) {
+    return ((status  & (GMIME_SIGNATURE_STATUS_RED | GMIME_SIGNATURE_STATUS_ERROR_MASK)) == 0);
+}
+
+gboolean
+g_mime_signature_status_bad (GMimeSignatureStatus status) {
+    return (status & GMIME_SIGNATURE_STATUS_RED);
+}
+
+gboolean
+g_mime_signature_status_error (GMimeSignatureStatus status) {
+    return (status & GMIME_SIGNATURE_STATUS_ERROR_MASK);
+}
+
 
 #endif
diff --git a/util/gmime-extra.h b/util/gmime-extra.h
index 3c16e46e..90f230c1 100644
--- a/util/gmime-extra.h
+++ b/util/gmime-extra.h
@@ -13,7 +13,6 @@ GMimeStream *g_mime_stream_stdout_new(void);
 #define GMIME_ADDRESS_TYPE_CC GMIME_RECIPIENT_TYPE_CC
 #define GMIME_ADDRESS_TYPE_BCC GMIME_RECIPIENT_TYPE_BCC
 
-
 #else /* GMime >= 3.0 */
 typedef GMimeAddressType GMimeRecipientType;
 
@@ -39,6 +38,9 @@ typedef GMimeAddressType GMimeRecipientType;
 #define internet_address_to_string(ia,encode) internet_address_to_string (ia,NULL,encode)
 #define internet_address_list_parse_string(str) internet_address_list_parse (NULL,str)
 typedef GMimeAddressType GMimeRecipientType;
+
+typedef GMimeSignatureStatus GMimeSignatureError;
+
 #endif
 
 /**
@@ -61,6 +63,7 @@ char *g_mime_message_get_date_string (void *ctx, GMimeMessage *message);
 
 InternetAddressList * g_mime_message_get_from (GMimeMessage *message);
 
+
 /**
  * return string for From: address
  * (owned by gmime)
@@ -73,4 +76,12 @@ InternetAddressList * g_mime_message_get_reply_to_list (GMimeMessage *message);
  * return talloc allocated reply-to string
  */
 char * g_mime_message_get_reply_to_string (void *ctx, GMimeMessage *message);
+
+void g_mime_parser_set_scan_from (GMimeParser *parser, gboolean flag);
+
+gboolean g_mime_signature_status_good (GMimeSignatureStatus status);
+
+gboolean g_mime_signature_status_bad (GMimeSignatureStatus status);
+
+gboolean g_mime_signature_status_error (GMimeSignatureError status);
 #endif
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 17/23] cli: hide rename of GMimeCertificateTrust

In reply to this post by David Bremner-2
Both the enum and the values are renamed in GMime 3.0.
---
 util/gmime-extra.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/util/gmime-extra.h b/util/gmime-extra.h
index 90f230c1..6b74724e 100644
--- a/util/gmime-extra.h
+++ b/util/gmime-extra.h
@@ -37,10 +37,20 @@ typedef GMimeAddressType GMimeRecipientType;
 #define g_mime_utils_header_decode_text(txt) g_mime_utils_header_decode_text (NULL, txt)
 #define internet_address_to_string(ia,encode) internet_address_to_string (ia,NULL,encode)
 #define internet_address_list_parse_string(str) internet_address_list_parse (NULL,str)
+
 typedef GMimeAddressType GMimeRecipientType;
 
 typedef GMimeSignatureStatus GMimeSignatureError;
 
+typedef GMimeTrust GMimeCertificateTrust;
+
+#define GMIME_CERTIFICATE_TRUST_UNKNOWN GMIME_TRUST_UNKNOWN
+#define GMIME_CERTIFICATE_TRUST_UNDEFINED GMIME_TRUST_UNDEFINED
+#define GMIME_CERTIFICATE_TRUST_NEVER GMIME_TRUST_NEVER
+#define GMIME_CERTIFICATE_TRUST_MARGINAL GMIME_TRUST_MARGINAL
+#define GMIME_CERTIFICATE_TRUST_FULLY GMIME_TRUST_FULL
+#define GMIME_CERTIFICATE_TRUST_ULTIMATE GMIME_TRUST_ULTIMATE
+
 #endif
 
 /**
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 18/23] lib: wrap use of g_mime_utils_header_decode_date

In reply to this post by David Bremner-2
This changes return type in gmime 3.0
---
 lib/message.cc     |  2 +-
 util/gmime-extra.c | 19 +++++++++++++++++++
 util/gmime-extra.h |  2 ++
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/lib/message.cc b/lib/message.cc
index b330dcce..f78e5a9d 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -1037,7 +1037,7 @@ _notmuch_message_set_header_values (notmuch_message_t *message,
     if (date == NULL || *date == '\0') {
  time_value = 0;
     } else {
- time_value = g_mime_utils_header_decode_date (date, NULL);
+ time_value = g_mime_utils_header_decode_date_unix (date);
  /*
  * Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=779923
  */
diff --git a/util/gmime-extra.c b/util/gmime-extra.c
index 350f75ea..3c50a293 100644
--- a/util/gmime-extra.c
+++ b/util/gmime-extra.c
@@ -99,6 +99,11 @@ g_mime_signature_status_error (GMimeSignatureError error) {
     return (error != GMIME_SIGNATURE_ERROR_NONE);
 }
 
+time_t
+g_mime_utils_header_decode_date_unix (const char *date) {
+    return g_mime_utils_header_decode_date (date, NULL);
+}
+
 #else /* GMime >= 3.0 */
 
 char *
@@ -166,5 +171,19 @@ g_mime_signature_status_error (GMimeSignatureStatus status) {
     return (status & GMIME_SIGNATURE_STATUS_ERROR_MASK);
 }
 
+gint64
+g_mime_utils_header_decode_date_unix (const char *date) {
+    GDateTime* parsed_date = g_mime_utils_header_decode_date (date);
+    time_t ret;
+
+    if (parsed_date) {
+ ret = g_date_time_to_unix (parsed_date);
+ g_date_time_unref (parsed_date);
+    } else {
+ ret = 0;
+    }
+
+    return ret;
+}
 
 #endif
diff --git a/util/gmime-extra.h b/util/gmime-extra.h
index 6b74724e..d744c4e4 100644
--- a/util/gmime-extra.h
+++ b/util/gmime-extra.h
@@ -94,4 +94,6 @@ gboolean g_mime_signature_status_good (GMimeSignatureStatus status);
 gboolean g_mime_signature_status_bad (GMimeSignatureStatus status);
 
 gboolean g_mime_signature_status_error (GMimeSignatureError status);
+
+gint64 g_mime_utils_header_decode_date_unix (const char *date);
 #endif
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH 19/23] lib: refactor _notmuch_messsage_file_get_combined_header

In reply to this post by David Bremner-2
We need to rewrite the loop for gmime-3.0; move the loop body to its
own function to avoid code duplication.  Keep the common exit via
"goto DONE" to make this pure code movement.  It's important to note
that the existing exit path only deallocates the iterator.
---
 lib/message-file.c | 57 ++++++++++++++++++++++++++++++------------------------
 1 file changed, 32 insertions(+), 25 deletions(-)

diff --git a/lib/message-file.c b/lib/message-file.c
index db18b163..7d38ebd0 100644
--- a/lib/message-file.c
+++ b/lib/message-file.c
@@ -201,6 +201,37 @@ _notmuch_message_file_get_mime_message (notmuch_message_file_t *message,
  *
  * Return NULL on errors, empty string for non-existing headers.
  */
+
+static char *
+_extend_header (char *combined, const char *value) {
+    char *decoded;
+
+    decoded = g_mime_utils_header_decode_text (value);
+    if (! decoded) {
+ if (combined) {
+    g_free (combined);
+    combined = NULL;
+ }
+ goto DONE;
+    }
+
+    if (combined) {
+ char *tmp = g_strdup_printf ("%s %s", combined, decoded);
+ g_free (decoded);
+ g_free (combined);
+ if (! tmp) {
+    combined = NULL;
+    goto DONE;
+ }
+
+ combined = tmp;
+    } else {
+ combined = decoded;
+    }
+ DONE:
+    return combined;
+}
+
 static char *
 _notmuch_message_file_get_combined_header (notmuch_message_file_t *message,
    const char *header)
@@ -222,37 +253,13 @@ _notmuch_message_file_get_combined_header (notmuch_message_file_t *message,
 
     do {
  const char *value;
- char *decoded;
-
  if (strcasecmp (g_mime_header_iter_get_name (iter), header) != 0)
     continue;
 
  /* Note that GMime retains ownership of value... */
  value = g_mime_header_iter_get_value (iter);
 
- /* ... while decoded needs to be freed with g_free(). */
- decoded = g_mime_utils_header_decode_text (value);
- if (! decoded) {
-    if (combined) {
- g_free (combined);
- combined = NULL;
-    }
-    goto DONE;
- }
-
- if (combined) {
-    char *tmp = g_strdup_printf ("%s %s", combined, decoded);
-    g_free (decoded);
-    g_free (combined);
-    if (! tmp) {
- combined = NULL;
- goto DONE;
-    }
-
-    combined = tmp;
- } else {
-    combined = decoded;
- }
+ combined = _extend_header (combined, value);
     } while (g_mime_header_iter_next (iter));
 
     /* Return empty string for non-existing headers. */
--
2.11.0

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
123
Loading...